public class

TimeFormatter

extends Object
java.lang.Object
   ↳ com.pnfsoftware.jeb.util.format.TimeFormatter

Class Overview

Utility methods to format timestamps and time deltas.

Summary

Public Constructors
TimeFormatter()
Public Methods
static String formatTimestamp(long unixTimestampMs, String timezone)
Format an epoch timestamp as using the following format:
 YYYY/MM/DD-hh:mm:ss
 
static String formatTimestamp(long unixTimestampMs)
Format an epoch timestamp as a UTC string using the following format:
 YYYY/MM/DD-hh:mm:ss
 
static String formatTimestampDelta(long deltaMs)
Format a time delta or time duration as a human-readable string.
static String formatTimestampLocal(long unixTimestampMs)
Format an epoch timestamp as a local, system specific date-and-time string.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public TimeFormatter ()

Public Methods

public static String formatTimestamp (long unixTimestampMs, String timezone)

Format an epoch timestamp as using the following format:

 YYYY/MM/DD-hh:mm:ss
 

Parameters
unixTimestampMs Unix epoch timestamp in milliseconds

public static String formatTimestamp (long unixTimestampMs)

Format an epoch timestamp as a UTC string using the following format:

 YYYY/MM/DD-hh:mm:ss
 

Parameters
unixTimestampMs Unix epoch timestamp in milliseconds

public static String formatTimestampDelta (long deltaMs)

Format a time delta or time duration as a human-readable string. The reported duration uses s, m, h, d for seconds, minutes, hours, and days.

Parameters
deltaMs delta or duration in milliseconds; it may be negative
Returns
  • the formatted rounded delta

public static String formatTimestampLocal (long unixTimestampMs)

Format an epoch timestamp as a local, system specific date-and-time string.

Parameters
unixTimestampMs Unix epoch timestamp in milliseconds