saker.util Documentation TaskDoc JavaDoc Packages
package saker.util
public class DateUtils
Utility class containing functions related to date and time usage.
Fields
public static final long
MS_PER_HOUR = 3600000L
Number of milliseconds in a hour.
public static final long
MS_PER_MINUTE = 60000L
Number of milliseconds in a minute.
public static final long
Number of milliseconds in a second.
public static final long
NANOS_PER_MS = 1000000L
Number of nanoseconds in a millisecond.
public static final long
NANOS_PER_SECOND = 1000000000L
Number of nanoseconds in a second.
Methods
public static String
Converts a time duration represented in milliseconds to a user readable string.
public static final long MS_PER_HOUR = 3600000L
Number of milliseconds in a hour.
public static final long MS_PER_MINUTE = 60000L
Number of milliseconds in a minute.
public static final long MS_PER_SECOND = 1000L
Number of milliseconds in a second.
public static final long NANOS_PER_MS = 1000000L
Number of nanoseconds in a millisecond.
public static final long NANOS_PER_SECOND = 1000000000L
Number of nanoseconds in a second.
public static String durationToString(long ms)
Converts a time duration represented in milliseconds to a user readable string.

This method will convert the argument duration into a string, having the following format:

 H hour(s) M minute(s) S.MILLIS second(s)
 
If a part in the above format contains 0 number, then it can be omitted only if there are no preceeding parts before it. The plural (s) sequences will be omitted for singular numbers.

Examples:

  • 0: 0 seconds
  • 1 000: 1 second
  • 1 234: 1.234 seconds
  • 60 000: 1 minute 0 seconds
  • 60 123: 1 minute 0.123 seconds
  • 3 600 000: 1 hour 0 minutes 0 seconds
msThe milliseconds to convert to string.
The string representation.