开发者

Java microseconds formatter

In database, i have 开发者_Python百科timestamp values like

2005-JAN-13 07:15:31.22222

I want to format above value in java to

2005-05-13 07:15:31.22222

fot this i used formetter: yyyy-MM-dd HH:mm:ss:SSSSS but when i use above formetter , it is giving value as follows:

2005-05-13 07:15:31:00222

instead of 2005-05-13 07:15:31.22222

can any one pls suggest java formater to get the value as follows:

2005-05-13 07:15:31.22222


AFAIK Java dates are up to millisecond precision, thus you can't format microseconds. The best you can get would be 2005-05-13 07:15:31.22200 (note that the trailing zeros would have to be appended by you, since the millisecond part would be 222 and thus would be formatted as 00222 when having the format string like SSSSS).


the standard date formats do not support microsecond precision. What you are getting is the milliseconds formatted into a 5 character wide millisecond field.

You would need to do your own manual formatting on microseconds and append it to the string yourself.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜