开发者

How to parse weird (for me) timestamp field

I want to parse an xml log file, using Java. The weird thing though is that it contains timestamps like this:

timestamp="1313932930.025" 

It does not really seem as a unix timestamp since at first look it's a double. Furthermore Java does not offer (to my knowledge) any contructor in the Timestamp class,开发者_StackOverflow that takes a Double argument.

Does anybody know what is this form and how could it be possibly parsed into a datetime human readable string?


It's a unix timestamp with fractional seconds. Multiply it by 1000 and then it's in milliseconds which is what Java is expecting.


Just remove the dot from that string and parse it as long.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜