4

Want to get time in milliseconds in android Ex 19:57:21:522.How do i do this?Could not find any straight forward API's to do so.

NitZRobotKoder
  • 1,046
  • 8
  • 44
  • 74
  • 1
    Check this http://stackoverflow.com/questions/16516888/how-to-get-current-date-time-in-milliseconds-in-android – Amit Sep 17 '13 at 08:00
  • 1
    http://stackoverflow.com/questions/8826270/how-to-convert-hhmmss-sss-to-milliseconds – Shakeeb Ayaz Sep 17 '13 at 08:06
  • possible duplicate of [Android get current time and date](http://stackoverflow.com/questions/5369682/android-get-current-time-and-date) – Dennis Meng Dec 07 '13 at 21:00

1 Answers1

12

Try SimpleDateFormat

http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html

Use a pattern with a capital S

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
String currentDateandTime = sdf.format(new Date());
Scary Wombat
  • 44,617
  • 6
  • 35
  • 64