我有两个时间戳:
2015-03-30T00:36:00.000+01002015-03-30T00:36:00.000+0200只有时区不同。在用DateTimeFormatter解析这个时间戳并使用DateTimeFormat.shortTime()打印时间(没有日期)之后。研究结果如下:
因为在我的例子中,只有时间是重要的,所以在打印时间时,我想忽略那些时区。如何实现打印两个时间戳的00:36?
发布于 2015-04-29 10:32:20
您可以使用固定长度的格式,这样您就可以这样做:
LocalDateTime ldt = LocalDateTime.parse(input, ISODateTimeFormat.dateTimeParser());
System.out.println(ldt.toLocalTime().toString(ISODateTimeFormat.hourMinute()));
// output: 00:36我使用LocalDateTime是因为您对时区偏移量不感兴趣。
https://stackoverflow.com/questions/29940906
复制相似问题