我有以下功能
public String getDateAndTimeInUserFormat(String value, DateTimeFormat inputFormat) {
return ZonedDateTime.parse(value, DateTimeFormatter.ofPattern(inputFormat.getFormat()))
.withZoneSameInstant(ZoneId.of(user().getTimezone()))
.format(DateTimeFormatter.ofPattern(user().getDateFormat() + " " + user().getTimeFormat()));
}
和以下测试
@Test
public void getDateAndTimeInUserFormat() throws Exception {
I18NService service = prepareForUserFormatCheck("####.000", "Brazil/Acre");
assertEquals(service.getDateAndTimeInUserFormat("2017-05-06T20:52:52+0200"),"06-05-2017 13:52");
assertEquals(service.getDateAndTimeInUserFormat("2017-12-06T20:52:52+0200"),"06-12-2017 13:52");
assertEquals(service.getDateAndTimeInUserFormat("2017-01-06T20:52:52+0200"),"06-01-2017 13:52");
assertEquals(service.getDateAndTimeInUserFormat("2017-03-06T20:52:52+0200"),"06-03-2017 13:52");
assertEquals(service.getDateAndTimeInUserFormat("2017-07-06T20:52:52+0200"),"06-07-2017 13:52");
assertEquals(service.getDateAndTimeInUserFormat("2017-09-06T20:52:52+0200"),"06-09-2017 13:52");
}
测试通过但不应该。根据我的理解,我应该收到一些相差一小时的结果。为什么我有相同的时间进行所有这些测试?