我正在尝试使用时区 UTC 将毫秒转换为时间戳,但它无法按预期工作,因为它转换为我的本地日期时间。
我尝试过以下。在调试代码时,我发现执行此命令时:new DateTime(eventDate)它工作正常,因为它的值是10:34:18.721,但后来 new Timestamp() 将其更改为 localdatetime。
long eventDate = 1566297258721L;
DateTimeZone.setDefault(DateTimeZone.UTC);
Timestamp timestamp = new Timestamp(new DateTime(eventDate).getMillis());
Run Code Online (Sandbox Code Playgroud)
我期望输出为:2019-08-20 10:34:18.721 但实际输出为:2019-08-20 12:34:18.721
我是测试新手。我试过这个,但有一个例外。
@Mock
private Context context;
...
when(service.getResult(any(), context)).thenReturn(new ArrayList<>());
Run Code Online (Sandbox Code Playgroud)
例外:
org.mockito.exceptions.misusing.InvalidUseOfMatchersException:
参数匹配器的使用无效!
预计 2 个匹配者,1 个记录: