Storing timestamp with milliseconds in Oracle

I know how to retrieve timestamp with milliseconds:

to_char(systimestamp ,'YYYY-MM-DD HH24:MI:SS,FF9')

Can anyone please advise, is the timestamp data type sufficient to store the date with milliseconds or can I use varchar2? I am trying to insert this value from Java.

Jon Skeet
people
quotationmark

Yes, TIMESTAMP allows precision down to nanoseconds if you want it.

If you only need milliseconds, you just want a TIMESTAMP(3) column.

Use a java.sql.Timestamp (which again goes down to nanoseconds, if you need it to) on the Java side. Note that you should avoid doing your to_char conversion if possible - perform any string conversions you need client-side; fetch data as a timestamp, and send it as a timestamp.

people

See more on this question at Stackoverflow