Java Time Format formatTimePeriod(long timestamp)

Here you can find the source of formatTimePeriod(long timestamp)

Description

format Time Period

License

Open Source License

Declaration

public static String formatTimePeriod(long timestamp) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String formatTimePeriod(long timestamp) {
        if (timestamp < 1000)
            return timestamp + " ms";
        if (timestamp < 60 * 1000)
            return (timestamp / 1000) + " sec";
        if (timestamp < 60 * 60 * 1000)
            return (timestamp / (1000 * 60)) + " min";
        if (timestamp < 24 * 60 * 60 * 1000)
            return (timestamp / (1000 * 60 * 60)) + " h";
        return (timestamp / (24 * 1000 * 60 * 60)) + " day";
    }//  w w  w. jav  a 2 s .c o m
}

Related

  1. formatTimeNicely(long millis)
  2. formatTimeOffset(long offset)
  3. formatTimePart2(long number, String unit)
  4. formatTimePeriod(long millis)
  5. formatTimePeriod(long timePeriod)
  6. formatTimeSec(long time)
  7. formatTimespan(int timespan)
  8. formatTimeSpanForScheduler(long time)
  9. formatTimestamp(String timestamp)