javadate

Get time with hour, minute, second, millisecond, microsecond


I have this code:

SimpleDateFormat sDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

I know that this code return hour, minute, second in the time. How i can get also the millisecond and microsecond??


Solution

  • You won't have microseconds, because a Date stores the number of milliseconds since Jan. 1 1970. For the milliseconds, use S, as documented in the javadoc.