Forums Register Login

Date milliseconds

+Pie Number of slices to send: Send
long time = System.currentTimeMillis();
SimpleDateFormat sdf = new SimpleDateFormat("MMM dd,yyyy HH:mm:ss:ms");

java.util.Date resultdate = new java.util.Date(time);
//java.util.Date resultdate1 = sdf.format(time); //returns String I want Date.
// java.util.Date resultdate = sdf.parse(Long.toString(time)); //gives Exception
System.out.println(sdf.format(resultdate));

Prints--Jan 11,2011 11:54:40:5440

I am confused that 999 is the max value for millisecond and value greter than this converts into seconds,then why is it showing 5440 ?

also I want to format "resultdate" into Date again. convering long to String and then formatting It ,is giving format exception
+Pie Number of slices to send: Send
What is "ms" in SimpleDateFormat ?
+Pie Number of slices to send: Send
milliseconds.
+Pie Number of slices to send: Send
Really ? Did you have a look at the API ? Do you see "ms" anywhere ?
+Pie Number of slices to send: Send
Sorry Christophe .Its "S"
+Pie Number of slices to send: Send
Yes. "SSS" should solve your problem
+Pie Number of slices to send: Send
Thanks a lot Christophe
+Pie Number of slices to send: Send
"ms" is nothing more than minutes followed by seconds - 54 followed by 40, combining into 5440.
+Pie Number of slices to send: Send
Yes, Rob Thanks.
And then we all jump out and yell "surprise! we got you this tiny ad!"
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 2600 times.
Similar Threads
Problem in Coverting one Date Format to Other date Format
integer number too large
date inserting
System Time with Milliseconds
org.hibernate.exception.GenericJDBCException: could not insert:
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 06:32:05.