-1
我需要格式化我在某個時區獲得的時間。 輸入日期字符串,我得到的是該類型的「2015-09-21T09:00:00 + 02:00」 我使用的這個過程的代碼是使用joda-time和parseDateTime格式化日期時間忽略第二部分
DateTimeZone fromTimeZone = DateTimeZone.forID("Europe/Paris");
DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ssZ").withZone(fromTimeZone);
DateTime cetDateTime = fmt.parseDateTime(inputDate);
return cetDateTime.toString();
但是這將返回「2015 - 09-21T09:00:00.000 + 02:00「,並添加第二部分。有沒有什麼辦法來抑制上述字符串中的分數?
您還沒有格式化'DateTime'。 –
使用'DateTimeFormatter'來以任何你想要的方式來格式化'DateTime' – MadProgrammer