Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/210.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何将时间戳转换为time4j矩格式?_Java_Android_Time4j - Fatal编程技术网

Java 如何将时间戳转换为time4j矩格式?

Java 如何将时间戳转换为time4j矩格式?,java,android,time4j,Java,Android,Time4j,我的Time4J库有问题,我无法将特定的时间戳转换为矩格式 例如,我想要这样的东西:Moment.timeinmilies=myTime或Moment.of(myTime) myTime是一个从纪元开始的long毫秒值,可以通过System.currentTimeMillis()编辑:我认为最好的转换是 TemporalType.MILLIS_SINCE_UNIX.translate(myTime) MILLIS\u因为UNIX可以在Long和Moment之间转换,所以调用会隐式地将Long框

我的Time4J库有问题,我无法将特定的时间戳转换为矩格式

例如,我想要这样的东西:
Moment.timeinmilies=myTime
Moment.of(myTime)


myTime
是一个从纪元开始的
long
毫秒值,可以通过
System.currentTimeMillis()
编辑:我认为最好的转换是

TemporalType.MILLIS_SINCE_UNIX.translate(myTime)
MILLIS\u因为UNIX
可以在
Long
Moment
之间转换,所以调用会隐式地将
Long
框起来

原始答案:我没有这方面的经验,但我阅读文档的方式应符合以下任一要求:

  • Moment.of(myTime/1000,Math.toIntExact(myTime%1000*1\u 000),TimeScale.POSIX)
  • moments.from(瞬间ofEpochMilli(myTime))
不过,我不知道,我可能错过了一种更优雅的方式

链接


@OleV.V。不,只是长格式的时间,一个可以通过System.currentTimeMillis()获得的值