commons-lang的FastDateFormat性能测试
commons-lang的FastDateFormat是一个thread-safe的,对SimpleDateFormat的一个重新实现。
public static long currentSystemTimeMillis() { FastDateFormat fdf = FastDateFormat.getInstance("yyyyMMddHHmmss");return Long.parseLong(fdf.format(System.currentTimeMillis())); }
public static long currentSystemTimeMillis() { Calendar rightNow = Calendar.getInstance(); rightNow.setTime(new Date(System.currentTimeMillis()));int year = rightNow.get(Calendar.YEAR);int month = rightNow.get(Calendar.MONTH) + 1;int day = rightNow.get(Calendar.DAY_OF_MONTH);int hour = rightNow.get(Calendar.HOUR_OF_DAY);int minute = rightNow.get(Calendar.MINUTE);int second = rightNow.get(Calendar.SECOND); String strDateTime = year + (month < 10 ? "0" + month : month + "") + (day < 10 ? "0" + day : day + "") + (hour < 10 ? "0" + hour : hour + "") + (minute < 10 ? "0" + minute : minute + "") + (second < 10 ? "0" + second : second + "");return Long.parseLong(strDateTime); }
public static void testDateFormat() throws Exception { System.out.println("Begin test of currentSystemTimeMillis()"); System.out.println("currentSystemTimeMillis:"+currentSystemTimeMillis());int tCnt = 50; Thread[] threads = new Thread[tCnt];for (int i = 0; i < tCnt; i++) { Runnable run = new Runnable() {public void run() {try {int runCounter = 0;for (long i = 0; i < 100000l; i++) { currentSystemTimeMillis(); runCounter++; } System.out.println(Thread.currentThread().getName() + " finished. runCounter=" + runCounter); } catch (Exception e) { } } }; threads[i] = new Thread(run, "Thread" + i); }long start = System.currentTimeMillis();for (int i = 0; i < tCnt; i++) { threads[i].start(); }for (int i = 0; i < tCnt; i++) { threads[i].join(); } System.out.println("Test ended cost:" + (System.currentTimeMillis() - start)); }
转载于:https://www.cnblogs.com/snowboyovo/archive/2012/02/28/2371200.html
commons-lang的FastDateFormat性能测试相关推荐
- Spark - Illegal pattern component: XXX 与org.apache.commons.lang3.time.FastDateFormat incompatible
一.引言 使用 sparkSession 读文件时出现 java.lang.IllegalArgumentException: Illegal pattern component: XXX 报错,解决 ...
- org.apache.commons.lang.StringUtils的jar包是什么
org.apache.commons.lang.StringUtils的jar包是什么 commons-lang-2.5.jar
- org.apache.commons.lang.StringUtils
org.apache.commons.lang.StringUtils 作为jdk中lang包的补充 检查CharSequence是否为空,null或者空格 CharSequence (CharBuf ...
- org.springframework.uti包下的StringUtils的使用和org.apache.commons.lang包下StringUtils的使用
一.org.springframework.util.StringUtils StringUtils常用方法 描述 boolean isEmpty(Object str) 判断字符串是否为空,如果为n ...
- guava和commons_使用Guava CharMatcher和Apache Commons Lang StringUtils确定字符串中字符或整数的存在...
guava和commons 最近Reddit上的帖子提出了一个问题:" 是否存在一种预定义的方法来检查变量值是否包含特定字符或整数? "基于问题的标题也被以另一种方式问到,&quo ...
- 使用Guava CharMatcher和Apache Commons Lang StringUtils确定字符串中字符或整数的存在
最近Reddit上的帖子提出了一个问题:" 是否存在一种预定义的方法来检查变量值是否包含特定字符或整数? "基于问题的标题也被以另一种方式问到,"一种检查变量是否包含诸如 ...
- Apache Commons Lang StringUtils
因此,认为最好谈论我喜欢的另一个Java库. 它已经存在了一段时间,也许不是最令人兴奋的库,但是它非常有用. 我可能每天都使用它. org.apache.commons.lang.StringUtil ...
- java commons lang 随机数_Apache Common-lang组件里随机数工具类RandomStringUtils的一个bug...
现在本文也转到了我自己的博客上,地址:月城小馆 Apache Common组件是java开发中常用的工具,其中的common-lang包是java基本数据类型的处理工具,包括数字.字符串.日期时间等多 ...
- apache.commons.lang.StringUtils 使用心得
apache.commons.lang.StringUtils 使用心得 转载于:https://www.cnblogs.com/qinglizlp/p/5549687.html
- apache commons lang架包介绍
commons lang组件介绍和学习 介绍 Java语言开发时有一个隐患,那就是java支持null值,这就导致很多时候操作可能会出异常. 因此很多第三方组件都会提供安全null safe 操作(即 ...
最新文章
- Liferay 6.1 用maven 构建 service-builder的巨大BUG的修复
- 我只会python、怎么搞个软件出来-python---很多行代码做一个自动打开软件的程序...
- dede日期时间标签调用大全
- Docker Swarm:经济高效的容器调度
- L1-048. 矩阵A乘以B
- 随手看的一本书《java微服务》,测试成功了其中的第一个样例
- PyTorch的nn.Linear()详解
- springboot 物联网_Confluent Kafka,KSQL,Spring Boot和分布式SQL开发物联网实战
- 矩形嵌套(NYOJ-16)
- HTTP 协议中的 Transfer-Encoding
- oracle的表连接-内外连接
- 创维E900V22C、E900V22D_S905L3A_安卓9.0_精简卡刷通刷固件包
- Xamarin 开发Android应用简易教程
- SVPWM算法原理及详解
- Mac删除Python缓存文件
- MGRE环境下的OSPF (实验超详解)
- BLOB/TEXT column ‘sup_content‘ used in key specification without a key length
- 什么是options请求?为什么会有options请求?
- IE8不支持jquery , xmlhttp.open() IE8 拒绝访问
- 赶快入手12代酷睿,畅享性能飞升体验-Acer掠夺者战斧300笔记本评测
热门文章
- MySQL5.5加主键锁读问题【转】
- 使用Visual Studio 2010 一步一步创建Powershell Module 和 Cmdlet
- POJ-1664 放苹果 动态规划思想解组合数学
- 新一代网络模式Web 2.0火爆发展
- Microsoft .NET 框架资源基础 ---摘自:msdn
- dos命令查看oracle_home,Oracle - OraDb10g_home1配置方法+DOS命令
- java corepoolsize_理解ThreadPoolExecutor线程池的corePoolSize、maximumPoolSize和poolSize
- mysql 赋给用户权限 grant all privileges on
- 最大公约数最小公倍数
- 昆士兰科技大学计算机专业,昆士兰科技大学QUT计算机科学Computer Science专业排名第101-125位(2021年THE世界大学商科排名)...