【发布时间】:2018-04-12 14:51:27
【问题描述】:
SimpleDateFormat 必须以何种格式从 unix 时间戳格式化为 unix 时间戳?
拥有此代码:
String format = System.getProperty("myformat");
SimpleDateFormat sdf = new SimpleDateFormat(format);
System.out.println(sdf.format(new java.util.Date(System.currentTimeMillis())));
我无法修改代码
myformat 属性的值必须是什么才能获得 Unix 时间戳?
【问题讨论】:
-
嗯,为什么要投反对票?
-
我没有投反对票,但您确定要使用 SimpleDateFormat 在 longs 上实现标识函数吗? (或者你的问题可能有错别字)
-
@Aaron 这是一个配置值,我只能修改配置值!
-
@PeterRader 那时我一定不明白你的问题。在您的问题中,“从 unix 时间戳到 unix 时间戳的格式”是什么意思?我假设您有一个框架强制您解析日期以生成时间戳,并且您有一个数据源已经是时间戳,但无论如何您都必须使用 SimpleDateFormat 进行解析,因此很难找到一种能够同时解析时间戳和格式化为时间戳。
标签: java unix-timestamp