| Author |
Date milliseconds
|
Punya Pratap Singh
Ranch Hand
Joined: Nov 23, 2010
Posts: 74
|
|
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
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14672
|
|
|
What is "ms" in SimpleDateFormat ?
|
[My Blog]
All roads lead to JavaRanch
|
 |
Punya Pratap Singh
Ranch Hand
Joined: Nov 23, 2010
Posts: 74
|
|
|
milliseconds.
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14672
|
|
|
Really ? Did you have a look at the API ? Do you see "ms" anywhere ?
|
 |
Punya Pratap Singh
Ranch Hand
Joined: Nov 23, 2010
Posts: 74
|
|
|
Sorry Christophe .Its "S"
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14672
|
|
Yes. "SSS" should solve your problem
|
 |
Punya Pratap Singh
Ranch Hand
Joined: Nov 23, 2010
Posts: 74
|
|
|
Thanks a lot Christophe
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
"ms" is nothing more than minutes followed by seconds - 54 followed by 40, combining into 5440.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Punya Pratap Singh
Ranch Hand
Joined: Nov 23, 2010
Posts: 74
|
|
|
Yes, Rob Thanks.
|
 |
 |
|
|
subject: Date milliseconds
|
|
|