多并发下 SimpleDateFormat 出现错误
2024-09-04 09:35:12
private static String time = "2019-01-11 11:11:11";
private static long timestamp = 1547176271000L;
private static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); public static void main(String[] args) {
dateFormatTest(x->{
try {
Date date = dateFormat.parse(time);
if (date.getTime() != timestamp){
System.out.println("转化错误:"+date);
}
} catch (Exception e) {
System.out.println("出现异常"+e.getMessage());
}
});
}
private static void dateFormatTest(Consumer runnable){
CountDownLatch countDownLatch = new CountDownLatch();
for (int i = ; i < ; i++) {
new Thread(()->{
runnable.accept(null);
countDownLatch.countDown();
}).start();
}
try {
countDownLatch.await();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
最新文章
- UNIX文件的权限之“设置用户ID位”
- 我的ORM之四--删除
- Python的下载与安装
- 理解 OpenStack Swift (1):OpenStack + 三节点Swift 集群+ HAProxy + UCARP 安装和配置
- Css - 文本溢出处理
- mysql操作类库--摘抄
- [SAP ABAP开发技术总结]OLE
- RMAN-03009 ORA-19504 ORA-27038
- HTTP 1.1与HTTP 1.0的比较
- 关于柯尼卡美能达bizhub250出现c2557错误解决方法
- 【转】来自《轻松scrum之旅》的敏捷开发总结
- centos6 qt ENV
- CentOS7 安装Bind
- 关于C++中虚函数表存放位置的思考
- 微信公众号订阅号以及服务号通过网页授权获取用户openid方法
- C# 1-2+3-4+5...+m的几种方法
- 迭代器&;迭代对象&;生成器
- springboot项目简单启动脚本
- 域名打开没有加上“http://”,导致报错{";code";:-32603,";message";:";Cannot navigate to invalid URL";}
- RFC2544测试指标
热门文章
- Centos7 使用 supervisor 管理进程
- MySQL8.0.16新特性:The Communication Protocol In Group Replication
- Git 分支管理 解决冲突
- bzoj4889: [Tjoi2017]不勤劳的图书管理员(树套树)
- 洛谷P2522 [HAOI2011]Problem b(莫比乌斯反演)
- 程序员收藏必看系列:深度解析MySOL优化(一)
- Spring+SpringMVC+JDBC实现登录
- 基于 Laravel Route 的 ThinkSNS+ Component
- npm ERR! missing script: build
- 常见的div布局面试题