完整源代码。。。
package com.ctc.web.client;
import java.time.Instant;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import org.junit.Assert;
import org.junit.Test;
public class WebConstantsTest {
@Test
public void test() {
Instant ts = Instant.parse("2020-01-01T04:05:55Z");
String format = DateTimeFormatter.ofPattern("YYYY-MM-dd HH:mm z").withZone(ZoneId.of("America/Los_Angeles")).format(ts);
Assert.assertEquals("2019-12-31 20:05 PST", format);
}
}
输出。。。
org.junit.ComparisonFailure: expected:<20[19]-12-31 20:05 PST> but was:<20[20]-12-31 20:05 PST>
at org.junit.Assert.assertEquals(Assert.java:115)
at org.junit.Assert.assertEquals(Assert.java:144)
at com.ctc.web.client.WebConstantsTest.test(WebConstantsTest.java:16)
休息一年
真实性检查
你可以使用几种可用的在线计算器中的任何一种来验证,当英国人在庆祝新年后4个小时基本上都在睡觉时,加州人仍然坐下来吃晚饭,因为他们还有4个小时的时间。