Package de.mhus.lib.core
Class MPeriod
- java.lang.Object
-
- de.mhus.lib.core.MPeriod
-
public class MPeriod extends Object
- Author:
- hummel To change the template for this generated type comment go to Window>Preferences>Java>Code Generation>Code and Comments
-
-
Field Summary
Fields Modifier and Type Field Description static intCENTURYstatic intDAYstatic longDAY_IN_MILLISECOUNDSstatic intDECADEstatic intHOURstatic longHOUR_IN_MILLISECOUNDSstatic intMILLENIUMstatic intMILLISECONDstatic intMINUTEstatic longMINUTE_IN_MILLISECOUNDSstatic intMONTHstatic longMONTH_AVERAGE_MILLISECONDSstatic intSECONDstatic longSECOUND_IN_MILLISECOUNDSstatic intWEEKstatic longWEEK_IN_MILLISECOUNDSstatic intYEARstatic longYEAR_AVERAGE_MILLISECONDS
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int _type, long _value)voidadd(MPeriod interval)longgetAllDays()longgetAllHours()longgetAllMilliseconds()longgetAllMinutes()longgetAllSecounds()longgetAllWeeks()longgetAverageMonths()longgetAverageYears()intgetDays()intgetHours()static StringgetIntervalAsString(long msec)static StringgetIntervalAsStringMin(long msec)static StringgetIntervalAsStringSec(long msec)intgetMilliseconds()intgetMinutes()intgetSeconds()static booleanisTimeOut(long start, long timeout)static booleanisTimeOut(long start, long stop, long timeout)voidjoin(Calendar _cal)Datejoin(Date _date)voidoptimize()voidparse(String _interval)static longtoMilliseconds(String interval, long def)Parse a string and returns an interval, possible formats are Secounds: 123425 Secounds and millis: 12345.123 Format: Day Hour:Minutes:Secounds.Millis or DD HH:MM:ss.SSS or ss, ss.SSS, MM:ss.SSS, HH:MM:ss.SSS, MM:ss, HH:MM:ssStringtoString()static longtoTime(String in, long def)
-
-
-
Field Detail
-
MONTH_AVERAGE_MILLISECONDS
public static final long MONTH_AVERAGE_MILLISECONDS
- See Also:
- Constant Field Values
-
YEAR_AVERAGE_MILLISECONDS
public static final long YEAR_AVERAGE_MILLISECONDS
- See Also:
- Constant Field Values
-
SECOUND_IN_MILLISECOUNDS
public static final long SECOUND_IN_MILLISECOUNDS
- See Also:
- Constant Field Values
-
MINUTE_IN_MILLISECOUNDS
public static final long MINUTE_IN_MILLISECOUNDS
- See Also:
- Constant Field Values
-
HOUR_IN_MILLISECOUNDS
public static final long HOUR_IN_MILLISECOUNDS
- See Also:
- Constant Field Values
-
DAY_IN_MILLISECOUNDS
public static final long DAY_IN_MILLISECOUNDS
- See Also:
- Constant Field Values
-
WEEK_IN_MILLISECOUNDS
public static final long WEEK_IN_MILLISECOUNDS
- See Also:
- Constant Field Values
-
MILLISECOND
public static final int MILLISECOND
- See Also:
- Constant Field Values
-
SECOND
public static final int SECOND
- See Also:
- Constant Field Values
-
MINUTE
public static final int MINUTE
- See Also:
- Constant Field Values
-
HOUR
public static final int HOUR
- See Also:
- Constant Field Values
-
DAY
public static final int DAY
- See Also:
- Constant Field Values
-
WEEK
public static final int WEEK
- See Also:
- Constant Field Values
-
MONTH
public static final int MONTH
- See Also:
- Constant Field Values
-
YEAR
public static final int YEAR
- See Also:
- Constant Field Values
-
DECADE
public static final int DECADE
- See Also:
- Constant Field Values
-
CENTURY
public static final int CENTURY
- See Also:
- Constant Field Values
-
MILLENIUM
public static final int MILLENIUM
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MPeriod
public MPeriod()
-
MPeriod
public MPeriod(long millisec)
-
MPeriod
public MPeriod(String _interval) throws NumberFormatException
- Throws:
NumberFormatException
-
-
Method Detail
-
parse
public void parse(String _interval) throws NumberFormatException
- Throws:
NumberFormatException
-
add
public void add(MPeriod interval)
-
add
public void add(int _type, long _value)
-
optimize
public void optimize()
-
join
public void join(Calendar _cal)
-
toMilliseconds
public static long toMilliseconds(String interval, long def)
Parse a string and returns an interval, possible formats are Secounds: 123425 Secounds and millis: 12345.123 Format: Day Hour:Minutes:Secounds.Millis or DD HH:MM:ss.SSS or ss, ss.SSS, MM:ss.SSS, HH:MM:ss.SSS, MM:ss, HH:MM:ss- Parameters:
interval-def-- Returns:
- milliseconds
-
getMilliseconds
public int getMilliseconds()
-
getSeconds
public int getSeconds()
-
getMinutes
public int getMinutes()
-
getHours
public int getHours()
-
getDays
public int getDays()
-
getAllMilliseconds
public long getAllMilliseconds()
-
getAllSecounds
public long getAllSecounds()
-
getAllMinutes
public long getAllMinutes()
-
getAllHours
public long getAllHours()
-
getAllDays
public long getAllDays()
-
getAllWeeks
public long getAllWeeks()
-
getAverageMonths
public long getAverageMonths()
-
getAverageYears
public long getAverageYears()
-
isTimeOut
public static boolean isTimeOut(long start, long stop, long timeout)
-
isTimeOut
public static boolean isTimeOut(long start, long timeout)
-
toTime
public static long toTime(String in, long def)
-
getIntervalAsString
public static String getIntervalAsString(long msec)
-
getIntervalAsStringSec
public static String getIntervalAsStringSec(long msec)
-
getIntervalAsStringMin
public static String getIntervalAsStringMin(long msec)
-
-