java.util.Date format SSSSSS: if not microseconds what are the last 3 digits? -
just tested code on both windows (8) workstation , aix:
public static void main(string[] args) { system.out.println(new simpledateformat("yyyy-mm-dd hh:mm:ss.ssssss").format(new date())); system.out.println(new simpledateformat("yyyy-mm-dd hh:mm:ss.ssssss").format(new date())); }
and got similar result:
2013-10-07 12:53:26.000905 2013-10-07 12:53:26.000906
can please explain me last digits, if not microseconds?
note: interact db2 database in chronological data stored using timed columns timestamp 6 digits after seconds i.e. microseconds (imo). "timestamps" created requesting following query:
select current timestamp currenttimestamp table ( values (1)) temp
i wonder if, given above results, couldn't use in code new date()
instead of selecting current timestamp
database.
thanks.
ps: searched found no relevant (answered) questions, like: current time in microseconds in java or get time hour, minute, second, millisecond, microsecond
from documentation of simpledateformat:
letter date or time component presentation examples s millisecond number 978
so milliseconds, or 1/1000th of second. format on 6 digits, add 3 leading zeroes...
you can check way:
date d =new date(); system.out.println(new simpledateformat("yyyy-mm-dd hh:mm:ss.s").format(d)); system.out.println(new simpledateformat("yyyy-mm-dd hh:mm:ss.ss").format(d)); system.out.println(new simpledateformat("yyyy-mm-dd hh:mm:ss.sss").format(d)); system.out.println(new simpledateformat("yyyy-mm-dd hh:mm:ss.ssss").format(d)); system.out.println(new simpledateformat("yyyy-mm-dd hh:mm:ss.sssss").format(d)); system.out.println(new simpledateformat("yyyy-mm-dd hh:mm:ss.ssssss").format(d));
output:
2013-10-07 12:13:27.132 2013-10-07 12:13:27.132 2013-10-07 12:13:27.132 2013-10-07 12:13:27.0132 2013-10-07 12:13:27.00132 2013-10-07 12:13:27.000132
Comments
Post a Comment