作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
Sample Julian Dates:
2009218
2009225
2009243
如何将它们转换为常规日期?
我尝试使用 online converter 转换它们我得到了-
12-13-7359 2009225!!毫无意义!
最佳答案
使用Joda-Time库并执行以下操作:
String dateStr = "2009218";
MutableDateTime mdt = new MutableDateTime();
mdt.setYear(Integer.parseInt(dateStr.subString(0,3)));
mdt.setDayOfYear(Integer.parseInt(dateStr.subString(4)));
Date parsedDate = mdt.toDate();
使用 Java API:
String dateStr = "2009218";
Calendar cal = new GregorianCalendar();
cal.set(Calendar.YEAR,Integer.parseInt(dateStr.subString(0,3)));
cal.set(Calendar.DAY_OF_YEAR,Integer.parseInt(dateStr.subString(4)));
Date parsedDate = cal.getTime();
---- 编辑 ----感谢 Alex 提供最佳答案:
Date myDate = new SimpleDateFormat("yyyyD").parse("2009218")
关于java - 儒略日期转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3036761/
我是一名优秀的程序员,十分优秀!