Is it simple way to get yyyy-MM-dd HH:mm:ss,SSS
from time in millisecond? I've found some information how to do this from new Date()
or Calendar.getInstance()
, but couldn't find if it can be done from long (e.g. 1344855183166
)
I thought you had asked how to get the time in this format "yyyy-MM-dd HH:mm:ss,SSS"
One way is to use java's SimpleDateFormat: http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html
NOTE that this is not thread-safe.
...
Date d = new Date(1344855183166L);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss,SSS");
String dateStr = sdf.format(d);
...
If you have epoch millis. The below line should work,
Instant.ofEpochMilli(millis).toString()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With