当前位置: 首页 > news >正文

tp框架做商城网站怎么用缓存wordpress u-degin

tp框架做商城网站怎么用缓存,wordpress u-degin,镇江佳鑫网络科技有限公司,亚马逊跨境电商平台官网java数字格式化当我看到其他人编写不必要的Java代码并且由于缺乏对已经提供所需功能的JDK类的了解而编写了不必要的Java代码时#xff0c;我会想到很多次。 这样的一个例子是时间相关的常量的使用硬编码值的写入#xff0c;如60 #xff0c; 24 #xff0c; 1440 #xff… java数字格式化 当我看到其他人编写不必要的Java代码并且由于缺乏对已经提供所需功能的JDK类的了解而编写了不必要的Java代码时我会想到很多次。 这样的一个例子是时间相关的常量的使用硬编码值的写入如60 24 1440 和86400时TIMEUNIT提供了更好的标准化的方法。 在这篇文章中我看一看一个类的示例该示例提供了开发人员经常在其上实现的功能 NumberFormat 。 NumberFormat类是java.text包的一部分该包还包括常用的DateFormat和SimpleDateFormat类。 NumberFormat是一个抽象类没有公共构造函数其后代的实例是通过具有诸如getInstance getCurrencyInstanceInstance和getPercentInstance之类的名称的重载静态方法获得的。 货币 下一个代码清单演示了如何调用NumberFormat.getCurrencyInstanceLocale来获取NumberFormat的实例该实例以货币友好格式显示数字。 演示NumberFormat的货币支持 /*** Demonstrate use of a Currency Instance of NumberFormat.*/ public void demonstrateCurrency() {writeHeaderToStandardOutput(Currency NumberFormat Examples);final NumberFormat currencyFormat NumberFormat.getCurrencyInstance(Locale.US);out.println(15.5 - currencyFormat.format(15.5));out.println(15.54 - currencyFormat.format(15.54));out.println(15.345 - currencyFormat.format(15.345)); // rounds to two decimal placesprintCurrencyDetails(currencyFormat.getCurrency()); }/*** Print out details of provided instance of Currency.** param currency Instance of Currency from which details* will be written to standard output.*/ public void printCurrencyDetails(final Currency currency) {out.println(Concurrency: currency);out.println(\tISO 4217 Currency Code: currency.getCurrencyCode());out.println(\tISO 4217 Numeric Code: currency.getNumericCode());out.println(\tCurrency Display Name: currency.getDisplayName(Locale.US));out.println(\tCurrency Symbol: currency.getSymbol(Locale.US));out.println(\tCurrency Default Fraction Digits: currency.getDefaultFractionDigits()); } 执行上述代码后结果如下所示 Currency NumberFormat Examples15.5 - $15.50 15.54 - $15.54 15.345 - $15.35 Concurrency: USDISO 4217 Currency Code: USDISO 4217 Numeric Code: 840Currency Display Name: US DollarCurrency Symbol: $Currency Default Fraction Digits: 2 上面的代码和相关的输出表明用于货币的NumberFormat实例实际上是DecimalFormat 会根据语言环境自动应用适当的位数和适当的货币符号。 百分比 下一个代码清单和相关的输出演示了NumberFormat使用以百分比友好格式显示数字。 演示NumberFormat的百分比格式 /*** Demonstrate use of a Percent Instance of NumberFormat.*/ public void demonstratePercentage() {writeHeaderToStandardOutput(Percentage NumberFormat Examples);final NumberFormat percentageFormat NumberFormat.getPercentInstance(Locale.US);out.println(Instance of: percentageFormat.getClass().getCanonicalName());out.println(1 - percentageFormat.format(1));// will be 0 because truncated to Integer by Integer divisionout.println(75/100 - percentageFormat.format(75/100));out.println(.75 - percentageFormat.format(.75));out.println(75.0/100 - percentageFormat.format(75.0/100));// will be 0 because truncated to Integer by Integer divisionout.println(83/93 - percentageFormat.format((83/93)));out.println(93/83 - percentageFormat.format(93/83));out.println(.5 - percentageFormat.format(.5));out.println(.912 - percentageFormat.format(.912));out.println(---- Setting Minimum Fraction Digits to 1:);percentageFormat.setMinimumFractionDigits(1);out.println(1 - percentageFormat.format(1));out.println(.75 - percentageFormat.format(.75));out.println(75.0/100 - percentageFormat.format(75.0/100));out.println(.912 - percentageFormat.format(.912)); }Percentage NumberFormat Examples1 - 100% 75/100 - 0% .75 - 75% 75.0/100 - 75% 83/93 - 0% 93/83 - 100% .5 - 50% .912 - 91% ---- Setting Minimum Fraction Digits to 1: 1 - 100.0% .75 - 75.0% 75.0/100 - 75.0% .912 - 91.2% 代码和百分比的输出NumberFormat使用表明通过默认的实例NumberFormat 实际上是一个DecimalFormat通过返回在这种情况下 NumberFormat.getPercentInstance区域的方法没有小数位乘所提供的数目由100假定它是如果提供则为百分数的十进制等效值 并添加一个百分号。 整数 接下来显示的少量代码及其相关输出演示了NumberFormat使用以整数格式显示数字。 演示NumberFormat的整数格式 /*** Demonstrate use of an Integer Instance of NumberFormat.*/ public void demonstrateInteger() {writeHeaderToStandardOutput(Integer NumberFormat Examples);final NumberFormat integerFormat NumberFormat.getIntegerInstance(Locale.US);out.println(7.65 - integerFormat.format(7.65));out.println(7.5 - integerFormat.format(7.5));out.println(7.49 - integerFormat.format(7.49));out.println(-23.23 - integerFormat.format(-23.23)); }Integer NumberFormat Examples7.65 - 8 7.5 - 8 7.49 - 7 -23.23 - -23 如上面的代码和相关输出所示 NumberFormat方法getIntegerInstanceLocale返回一个实例该实例将提供的数字表示为整数。 固定位数 下一个代码清单和相关的输出演示了如何使用NumberFormat打印浮点数的定点表示形式。 换句话说使用NumberFormat可以表示一个数字该数字在小数点左边“整数”数字和小数点右边“小数”数字正好具有规定位数。 演示定点数字的NumberFormat /*** Demonstrate generic NumberFormat instance with rounding mode,* maximum fraction digits, and minimum integer digits specified.*/ public void demonstrateNumberFormat() {writeHeaderToStandardOutput(NumberFormat Fixed-Point Examples);final NumberFormat numberFormat NumberFormat.getNumberInstance();numberFormat.setRoundingMode(RoundingMode.HALF_UP);numberFormat.setMaximumFractionDigits(2);numberFormat.setMinimumIntegerDigits(1);out.println(numberFormat.format(234.234567));out.println(numberFormat.format(1));out.println(numberFormat.format(.234567));out.println(numberFormat.format(.349));out.println(numberFormat.format(.3499));out.println(numberFormat.format(0.9999)); }NumberFormat Fixed-Point Examples234.23 1 0.23 0.34 0.35 1 上面的代码和相关的输出演示了对最小“整数”位数的精确控制该位数代表小数点左边至少一个因此在适用时显示为零和最大“分数”小数点右边的数字。 尽管未显示但也可以指定最大整数位数和最小分数位数。 结论 我曾经用过这篇文章来研究如何使用NumberFormat来以不同的方式货币百分比整数固定的小数点等表示数字并且通常意味着不需要编写或减少代码来对这些数字进行按摩格式。 当我第一次开始写这篇文章时我设想包括有关NumberFormat的直接后代 DecimalFormat和ChoiceFormat 的示例和讨论但是已经确定这篇文章已经足够冗长了。 我可能会在以后的博客文章中介绍NumberFormat这些后代。 翻译自: https://www.javacodegeeks.com/2014/08/java-numeric-formatting.htmljava数字格式化
http://www.huolong8.cn/news/159691/

相关文章:

  • 网站开发方面知识开家网站建设培训
  • 网站建设还能赚钱吗国家信息公示网
  • 好商网的网站可以做中英文切换吗凡科建站免费版可以做什么
  • 网站建设与设计实验报告中国建设银行网站密码是什么意思
  • 网站多语言 设计网站搜索功能怎么做
  • 太原seo网站建设上海公司网站备案
  • 学院门户网站建设汕头人口
  • 电子商务网站的主题及建设目标微网站设计制作
  • 四川省城乡与建设厅网站首页淘宝直通车推广怎么收费
  • 中国建设银行演示网站外贸网站建设外
  • 看一个网站是用什么语言做的群晖 wordpress是什么
  • 网站功能模块有哪些深圳电商页面设计那家好
  • 站酷设计官方网站网站开发宝典
  • 安徽省建设监理有限公司网站自己制作app的应用程序
  • 重庆网站建设网站建设建立一个公司
  • 浏阳网站建设tvshown国外h5建站
  • linux建立网站南京网站开发选南京乐识赞
  • 织梦建设网站全过程三河建设厅公示网站
  • 做宣传图片用什么网站宣传片拍摄流程
  • 自己开发网站需要多少钱简易手机app制作教程
  • wordpress注册页岳阳优化营商环境
  • 宁波市网站建设专做展厅设计网站
  • 网站空间 虚拟主机谷歌seo优化怎么做
  • 广东网站推广策略哈尔滨证件制作
  • ip域名找网站直播app开发价格
  • wordpress自建电商网站网站注销申请
  • 基于c 的网站开发家具营销型网站模板
  • 中国做的比较好的网站包头市建设工程安全监督站网站
  • 网站怎么注册一个网站建设的课程设计书
  • 路南网站建设wordpress shortcodes