Follow the links below to browse sample Javadoc for MJ classes and tools, including the MJ Runtime Library.

 

Package: com.arsi.mj.text.timefmt  previous next contents

The timefmt package contains the formatting implementations related to times. In general, these utilities should always be used via static reference if one is available.

When a date is coerced into a time, the number of days since the minimum valid date are treated as the number of hours (modulo 24 if not an elapsed format); as there is no fractional piece, minutes and seconds are not available. When a number is coerced into a time, the integer portion is treated as the number of hours (modulo 24 if not an elapsed format); fractional content is treated as fractions of an hour, and is converted into minutes and seconds.

The sign of the coerced numeric value determines whether the resulting "time" is added to or subtracted from 24-hour midnight. If the numeric input is positive (e.g., "2"), the time value is the clockwise addition result ("02:00:00"). If the numeric input is negative (e.g., "-2"), the time value is the counter-clockwise subtraction result ("22:00:00").

Time values are constrained as follows:
Chart shows time format names, a description, various presentations, and the raw pattern used.
Format Reference Description Presentation of 6:32:41 AM Presentation of 150645.141 Presentation of -73.206 Format Pattern
Time0 Presents input in a time format 06:32:41 21:08:28 23:47:38 HH:mm:ss
Time1 Presents input in a time format 06:32 21:08 23:47 HH:mm
Time2 Presents input in a time format 063241 210828 234738 HHmmss
Time3 Presents input in a time format 0632 2108 2347 HHmm
Time4 Presents input in an elapsed time format 06:32:41 150645:08:28 -73.206 HHHHHHH:mm:ss
Time5 Presents input in an elapsed time format 06:32 150645:08 -73.206 HHHHHHH:mm
TimeH Presents input in a time format 6 21 23 H
TimeM Presents input in a time format 32 8 47 m
TimeS Presents input in a time format 41 28 38 s
Classes and Interfaces
CustomTimeFormatBase Custom format base class for all time formats; needed since FastDateFormat does not handle roll-over (hours modulo 24) or numbers of hours greater than 24.
ElapsedTimeFormatBase Custom format base class for all time formats; needed since FastDateFormat does not handle roll-over (hours modulo 24) or numbers of hours greater than 24.
Time0Format Custom date format class for time format TIME0$ (implements the pattern HH:MM:SS).
Time1Format Custom date format class for time format TIME1$ (implements the pattern HH:MM).
Time2Format Custom date format class for time format TIME2$ (implements the pattern HHMMSS).
Time3Format Custom date format class for time format TIME3$ (implements the pattern HHMM).
Time4Format Custom date format class for elapsed time format TIME4$ (implements the pattern HHHHHHH:mm:ss); needed since the formatting logic counts days where hours should be, as related to the low end of the permitted range.
Time5Format Custom date format class for elapsed time format TIME5$ (implements the pattern HHHHHHH:mm); needed since the formatting logic counts days where hours should be, as related to the low end of the permitted range.
TimeHFormat Custom date format class for the @CAL time format T(H) (implements the pattern H).
TimeMFormat Custom date format class for the @CAL time format T(M) (implements the pattern M).
TimeSFormat Custom date format class for the @CAL time format T(S) (implements the pattern S).
TimeTuple Specialized encapsulation for time data.

Class: CustomTimeFormatBase   next package

Custom format base class for all time formats; needed since FastDateFormat does not handle roll-over (hours modulo 24) or numbers of hours greater than 24.

Treat this class as "thread-safe" (actually it relies on the thread safety of FastDateFormat).
public abstract class com.arsi.mj.text.timefmt.CustomTimeFormatBase
  extends com.arsi.mj.text.CustomDateTimeFormat
Fields
Month and day part of formatting are delegated to this instance.
protected final org.apache.commons.lang3.time.FastDateFormat fmtDelegate
Constructors
Ctor for initializing an instance of this class.
Parameters:
aPattern - the pattern to use for formatting
protected CustomTimeFormatBase(java.lang.String aPattern)
Ctor for initializing an instance of this class.
Parameters:
aPattern - the pattern to use for formatting
aFormat - the format for content display
protected CustomTimeFormatBase(java.lang.String aPattern, com.arsi.mj.text.FormatOption aFormat)
Methods
Implementation that replaces basic formatting with results from custom formatting.
See Also:
org.apache.commons.lang3.time.FastDateFormat#applyRules(java.util.Calendar, java.lang.StringBuffer)
protected java.lang.StringBuffer applyRules(java.util.Calendar aCalendar, java.lang.StringBuffer aBuffer)
Converts the calendar information into a time-only encapsulation.
Parameters:
aCalendar - the conversion target
aBuffer - the target buffer for additional content
Returns:
time-only calendar information
protected java.util.Calendar convertToTimeCalendar(java.util.Calendar aCalendar, java.lang.StringBuffer aBuffer)
Processes the numeric data into time format.
Parameters:
aNumericValue - the value to represent
aTargetBuffer - the existing content
Returns:
the concatenation of the format result
protected java.lang.StringBuffer format(double aNumericValue, java.lang.StringBuffer aTargetBuffer)

Customizes the base implementation to handle the Mapper time/date coercion logic. Any input that derives from Number will be treated as a non-date value.

See the package-level documentation for examples of numeric processing.

See Also:
org.apache.commons.lang3.time.FastDateFormat#format(java.lang.Object, java.lang.StringBuffer, java.text.FieldPosition), com.arsi.mj.text.timefmt
public java.lang.StringBuffer format(java.lang.Object anObject, java.lang.StringBuffer aTargetBuffer, java.text.FieldPosition aPosition)

Class: ElapsedTimeFormatBase   previous next package

Custom format base class for all time formats; needed since FastDateFormat does not handle roll-over (hours modulo 24) or numbers of hours greater than 24.

Treat this class as "thread-safe" (actually it relies on the thread safety of FastDateFormat).
public abstract class com.arsi.mj.text.timefmt.ElapsedTimeFormatBase
  extends com.arsi.mj.text.timefmt.CustomTimeFormatBase
Constructors
Ctor for initializing an instance of this class.
Parameters:
aPattern - the pattern to use for formatting
protected ElapsedTimeFormatBase(java.lang.String aPattern)
Methods
Generates a calendar instance suitable for elapsed time formatting.
See Also:
com.arsi.mj.text.timefmt.CustomTimeFormatBase#convertToTimeCalendar(java.util.Calendar, java.lang.StringBuffer)
protected java.util.Calendar convertToTimeCalendar(java.util.Calendar aCalendar, java.lang.StringBuffer aBuffer)
Processes the numeric data into time format.
Parameters:
aNumericValue - the value to represent
aTargetBuffer - the existing content
Returns:
the concatenation of the format result
protected java.lang.StringBuffer format(double aNumericValue, java.lang.StringBuffer aTargetBuffer)

Class: Time0Format   previous next package

Custom date format class for time format TIME0$ (implements the pattern HH:MM:SS).

Treat this class as "thread-safe" (actually it relies on the thread safety of FastDateFormat).
public class com.arsi.mj.text.timefmt.Time0Format
  extends com.arsi.mj.text.timefmt.CustomTimeFormatBase
Constructors
Public ctor for initializing an instance of this class.
public Time0Format()

Class: Time1Format   previous next package

Custom date format class for time format TIME1$ (implements the pattern HH:MM).

Treat this class as "thread-safe" (actually it relies on the thread safety of FastDateFormat).
public class com.arsi.mj.text.timefmt.Time1Format
  extends com.arsi.mj.text.timefmt.CustomTimeFormatBase
Constructors
Public ctor for initializing an instance of this class.
public Time1Format()

Class: Time2Format   previous next package

Custom date format class for time format TIME2$ (implements the pattern HHMMSS).

Treat this class as "thread-safe" (actually it relies on the thread safety of FastDateFormat).
public class com.arsi.mj.text.timefmt.Time2Format
  extends com.arsi.mj.text.timefmt.CustomTimeFormatBase
Constructors
Public ctor for initializing an instance of this class.
public Time2Format()

Class: Time3Format   previous next package

Custom date format class for time format TIME3$ (implements the pattern HHMM).

Treat this class as "thread-safe" (actually it relies on the thread safety of FastDateFormat).
public class com.arsi.mj.text.timefmt.Time3Format
  extends com.arsi.mj.text.timefmt.CustomTimeFormatBase
Constructors
Public ctor for initializing an instance of this class.
public Time3Format()

Class: Time4Format   previous next package

Custom date format class for elapsed time format TIME4$ (implements the pattern HHHHHHH:mm:ss); needed since the formatting logic counts days where hours should be, as related to the low end of the permitted range.

Treat this class as "thread-safe" (actually it relies on the thread safety of FastDateFormat).
public class com.arsi.mj.text.timefmt.Time4Format
  extends com.arsi.mj.text.timefmt.ElapsedTimeFormatBase
Constructors
Public ctor for initializing an instance of this class.
public Time4Format()

Class: Time5Format   previous next package

Custom date format class for elapsed time format TIME5$ (implements the pattern HHHHHHH:mm); needed since the formatting logic counts days where hours should be, as related to the low end of the permitted range.

Treat this class as "thread-safe" (actually it relies on the thread safety of FastDateFormat).
public class com.arsi.mj.text.timefmt.Time5Format
  extends com.arsi.mj.text.timefmt.ElapsedTimeFormatBase
Constructors
Public ctor for initializing an instance of this class.
public Time5Format()

Class: TimeHFormat   previous next package

Custom date format class for the @CAL time format T(H) (implements the pattern H).

Treat this class as "thread-safe" (actually it relies on the thread safety of FastDateFormat).
public class com.arsi.mj.text.timefmt.TimeHFormat
  extends com.arsi.mj.text.timefmt.CustomTimeFormatBase
Constructors
Public ctor for initializing an instance of this class.
public TimeHFormat()

Class: TimeMFormat   previous next package

Custom date format class for the @CAL time format T(M) (implements the pattern M).

Treat this class as "thread-safe" (actually it relies on the thread safety of FastDateFormat).
public class com.arsi.mj.text.timefmt.TimeMFormat
  extends com.arsi.mj.text.timefmt.CustomTimeFormatBase
Constructors
Public ctor for initializing an instance of this class.
public TimeMFormat()

Class: TimeSFormat   previous next package

Custom date format class for the @CAL time format T(S) (implements the pattern S).

Treat this class as "thread-safe" (actually it relies on the thread safety of FastDateFormat).
public class com.arsi.mj.text.timefmt.TimeSFormat
  extends com.arsi.mj.text.timefmt.CustomTimeFormatBase
Constructors
Public ctor for initializing an instance of this class.
public TimeSFormat()

Class: TimeTuple   previous package

Specialized encapsulation for time data.

Treat this class as "thread-safe", as it is immutable once instantiated.
public class com.arsi.mj.text.timefmt.TimeTuple
  extends java.lang.Object
Fields
The number of hours contained in the tuple. Input values can be out of the range of what would normally be considered valid.
public final long hours
The number of minutes contained in the tuple; will be less than 60.
public final long minutes
The number of seconds contained in the tuple; will be less than 60.
public final long seconds
The value to use in determining whether the time should be calculated as a forward or backward interval; positive intervals are forward, and negative intervals are backward.
public final int signMultiplier
Methods
Convert a numeric value into an {hour}:{minute}:{second} construct that can then be formatted.
Parameters:
aNumericValue - the value to parse
Returns:
the extracted time data
public static com.arsi.mj.text.timefmt.TimeTuple parseTime(double aNumericValue)