This is my code:
long currentTime = System.currentTimeMillis();
Date date = new Date(currentTime); // if you really have long
String result = new SimpleDateFormat("HH:mm:ss").format(date.getTime());
Is it possible to add milliseconds and nanoseconds to the date format ?
You can add milliseconds by adding
SSSat the end, such as the format will beHH:mm:ss.SSS.There is no reference in the
SimpleDateFormatto nanoseconds. UsuallySystem.nanoTime()is used for performance debugging and not for display purposes.