user1924249
user1924249

Reputation: 566

how to format time in java?

How to format time in libgdx(java)?

long startTime = System.currentTimeMillis();
System.out.println(TimeUtils.timeSinceMillis(startTime));

I want to format like this:

min:sec:mil

00:00:00 or 00:00:000

Upvotes: 0

Views: 91

Answers (1)

Semih Eker
Semih Eker

Reputation: 2409

Try like this;

    long startTime = System.currentTimeMillis();
    SimpleDateFormat sDate = new SimpleDateFormat("mm:ss.SSS");
    System.out.println(sDate.format(startTime));

Output is;

05:42.331

If you want also with hour;

Format sDate = new SimpleDateFormat("HH:mm:ss.SSS");

Upvotes: 2

Related Questions