com.netflix.infix
Class TimeUtil

java.lang.Object
  extended by com.netflix.infix.TimeUtil

public class TimeUtil
extends java.lang.Object


Constructor Summary
TimeUtil()
           
 
Method Summary
static org.joda.time.format.DateTimeFormatter toDateTimeFormatter(java.lang.String formatName, java.lang.String timeFormat)
          Converts the given time format string to a DateTimeFormatter instance.
static java.lang.String toString(long millis, java.lang.String format)
          Converts the given epoch time in millisecond to a string according to the given format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimeUtil

public TimeUtil()
Method Detail

toDateTimeFormatter

public static org.joda.time.format.DateTimeFormatter toDateTimeFormatter(java.lang.String formatName,
                                                                         java.lang.String timeFormat)
Converts the given time format string to a DateTimeFormatter instance.

Parameters:
formatName - A name used to identify the given time format. This is mainly used for error reporting.
timeFormat - The date time format to be converted.
Returns:
A DateTimeFormatter instance of the given time format.
Throws:
java.lang.IllegalArgumentException - if the given time format is invalid.

toString

public static java.lang.String toString(long millis,
                                        java.lang.String format)
Converts the given epoch time in millisecond to a string according to the given format. Note each invocation creates a new DateTimeFormatter instance, which is pretty costly. This method is suitable for testing and calls that are not on hot path.

Parameters:
millis - the epoch time to be converted
format - The format the returned time string
Returns:
A string representation of the given epoch time in the given format