Package com.mckoi.util
Class TimeFrame
java.lang.Object
com.mckoi.util.TimeFrame
An immutable object that represents a frame of time down to the
accuracy of a millisecond.
This object wraps around a BigDecimal that represents the number of milliseconds it takes to pass through the period.
- Author:
- Tobias Downer
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns a Date that is the addition of this period of time to the given date.boolean
Returns true if the TimeFrame is equal to another.format
(int format_type) Returns a string that represents this time frame formatted as a string.format
(int format_type, boolean shorthand) Returns a string that represents this time frame formatted as a string.Returns the number of milliseconds for the period of this time frame.boolean
isNoTime()
Returns true if this time frame represents no time.static TimeFrame
Parses the given String and returns a TimeFrame object that represents the date.toString()
For Debugging.
-
Field Details
-
WEEKS
public static int WEEKSFormatting enum. -
DAYS
public static int DAYSFormatting enum. -
HOURS
public static int HOURSFormatting enum. -
MINUTES
public static int MINUTESFormatting enum.
-
-
Constructor Details
-
TimeFrame
Constructs the TimeFrame for the given time.
-
-
Method Details
-
getPeriod
Returns the number of milliseconds for the period of this time frame. -
isNoTime
public boolean isNoTime()Returns true if this time frame represents no time. -
addToDate
Returns a Date that is the addition of this period of time to the given date. -
format
Returns a string that represents this time frame formatted as a string. The period is formatted as short hand.- Parameters:
format_type
- either WEEKS, HOURS, MINUTES
-
format
Returns a string that represents this time frame formatted as a string.- Parameters:
format_type
- either WEEKS, HOURS, MINUTESshorthand
- if false then timeframe is formatted in long hand. 'ms' -> 'milliseconds'
-
parse
Parses the given String and returns a TimeFrame object that represents the date. This excepts strings such as:"3 wks 12 days", "5.4 days", "9d", "12 minutes", "24 mins", etc.
See 'GeneralParser' for more details.
- Throws:
ParseException
-
equals
Returns true if the TimeFrame is equal to another. -
toString
For Debugging.
-