Elexis API documentation
Version 2.1.6 as of December 11 2011

ch.rgw.tools
Class TimeTool

java.lang.Object
  extended by java.util.Calendar
      extended by java.util.GregorianCalendar
          extended by ch.rgw.tools.TimeTool
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<java.util.Calendar>

public class TimeTool
extends java.util.GregorianCalendar

Klasse zur einfachen Datum- und Zeitberarbeitung

Author:
G. Weirich
See Also:
Serialized Form

Nested Class Summary
static class TimeTool.TimeFormatException
           
 
Field Summary
static java.lang.String BEGINNING_OF_UNIX_EPOCH
          first day that can be set into a TimeTool
static int DATE_COMPACT
          Constant indicating a compact date format (yyyyMMdd)
static int DATE_GER
          Constant indicating a date in german notation (dd.mm.yy)
static int DATE_ISO
          Constant indicating a date format in ISO notation (yyyyy-MM-dd)
static int DATE_MYSQL
          Constant indicating a date format in ISO notation (yyyyy-MM-dd)
static int DATE_SIMPLE
          Constant indicating a simple date in the preferred format
static int DATETIME_XML
          Constant indicating an XML Datetime format (yyyy-MM-ddThh:mm:ss)
static java.lang.String END_OF_UNIX_EPOCH
          last date a TimeTool can be set to
static int FULL
          Constant indicating a full date in the preferred format
static int FULL_GER
          Constant indicating a full date/time format in german notation (dd.MM.yyyyy hh:mm:ss)
static int FULL_ISO
          Constant indicating a full date/time format in ISO notation (yyyyy-MM-dd hh:mm:ss)
static int FULL_MYSQL
          Constant indicating a full date/time format in ISO notation (yyyyy-MM-dd hh:mm:ss)
static int LARGE_GER
          Constant indicating a large date/time format in german notation (dd.MM.yyyyy hh:mm)
static java.lang.String[] Mon
          Month names as three-letter-abbreviations
static java.lang.String[] Monate
          Month names as full words
static java.lang.String[] month_eng
           
static int TIME_COMPACT
          Constant indicating a compact time format (hhmm)
static int TIME_FULL
          Constant indicating a full time format (hh:mm:ss)
static int TIME_SMALL
          Constant indicating a small time format (hh:mm)
static int TIMESTAMP
          Constant indicating a timestamp format (yyyyMMddhhmmss)
static java.lang.String[] wdays
          Weekdays as abbreviations
static int WEEKDAY
           
static java.lang.String[] Wochentage
          weekdays as full words
 
Fields inherited from class java.util.GregorianCalendar
AD, BC
 
Fields inherited from class java.util.Calendar
ALL_STYLES, AM, AM_PM, APRIL, AUGUST, DATE, DAY_OF_MONTH, DAY_OF_WEEK, DAY_OF_WEEK_IN_MONTH, DAY_OF_YEAR, DECEMBER, DST_OFFSET, ERA, FEBRUARY, FIELD_COUNT, FRIDAY, HOUR, HOUR_OF_DAY, JANUARY, JULY, JUNE, LONG, MARCH, MAY, MILLISECOND, MINUTE, MONDAY, MONTH, NOVEMBER, OCTOBER, PM, SATURDAY, SECOND, SEPTEMBER, SHORT, SUNDAY, THURSDAY, TUESDAY, UNDECIMBER, WEDNESDAY, WEEK_OF_MONTH, WEEK_OF_YEAR, YEAR, ZONE_OFFSET
 
Constructor Summary
TimeTool()
          create a TimeTool set to the current date/time
TimeTool(int t, int res)
          Create a TimeTool set to the given units
TimeTool(long millis)
          Create a TimeTool set to the specified milliseconds
TimeTool(java.lang.String pre)
          Create a TimeTool set to a date/time as indicated by a String
TimeTool(java.lang.String pre, boolean bFailIfInvalid)
          Create a TimeTool set to a date/time as indicated by a String
TimeTool(TimeTool other)
          Create a TimeTool set to another TimeTool's date/time
 
Method Summary
 void addDays(int d)
           
 void addHours(int h)
           
 void addMinutes(int m)
           
 void addSeconds(int s)
           
 void addUnits(int m)
           
 void chop(int w)
          Inhalt kürzen.
 int compareTo(java.util.Calendar arg0)
           
 int daysTo(TimeTool o)
          Return the number of daysd between (including) this and (excluding) an other TimeTool
 long diff(TimeTool o, long res)
          Differenz zu einem anderen TimeTool, ausgedrückt in "resolution"-Einheiten
 java.lang.String dump()
           
static int getMinutesFromTimeString(java.lang.String in)
          Parse a String for time information and return these in minutes
static int getSecondsFromTimeString(java.lang.String in)
          Parse a String for time information and return these in seconds
 long getTimeAsLong()
           
static int getTimeInSeconds()
          return the time as seconds
 int getTimeInUnits()
           
 int hashCode()
           
 boolean isAfter(TimeTool o)
           
 boolean isAfterOrEqual(TimeTool o)
           
 boolean isBefore(TimeTool o)
           
 boolean isBeforeOrEqual(TimeTool o)
           
 boolean isEqual(TimeTool o)
           
 boolean isSameDay(TimeTool o)
          Checks whether two TimeTool values represent the same day (ignoring the time)
static int minutesStringToInt(java.lang.String in)
           
static int[] parseDate(java.lang.String tx)
           
static int[] parseTime(java.lang.String tx)
          Zerlegt einen Zeitstring in Stunden- Minuten- und Sekundenanteile
 int secondsTo(TimeTool o)
           
 void set(java.util.GregorianCalendar gcal)
           
 boolean set(java.lang.String orig)
          Parsed einen String im Format "datum zeit" oder "datum, zeit" oder "datum" oder "zeit".
 void set(TimeTool o)
           
 void setAsUnits(int d)
           
 boolean setDate(java.lang.String dat)
          Set the date, leave the Time untouched
 void setDate(TimeTool o)
          Set the date to the value of another TimeTool.
static void setDefaultResolution(int r)
           
static void setPreferredFormat(java.lang.String full, java.lang.String small, java.lang.String wr)
           
 void setResolution(long res)
           
 void setTime(TimeTool o)
          Set the time, leave the date untouched
 java.lang.String toDBString(boolean full)
           
 java.lang.String toString()
           
 java.lang.String toString(int f)
           
static java.lang.String Version()
           
 
Methods inherited from class java.util.GregorianCalendar
add, clone, equals, getActualMaximum, getActualMinimum, getGreatestMinimum, getGregorianChange, getLeastMaximum, getMaximum, getMinimum, getTimeZone, isLeapYear, roll, roll, setGregorianChange, setTimeZone
 
Methods inherited from class java.util.Calendar
after, before, clear, clear, get, getAvailableLocales, getDisplayName, getDisplayNames, getFirstDayOfWeek, getInstance, getInstance, getInstance, getInstance, getMinimalDaysInFirstWeek, getTime, getTimeInMillis, isLenient, isSet, set, set, set, set, setFirstDayOfWeek, setLenient, setMinimalDaysInFirstWeek, setTime, setTimeInMillis
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

BEGINNING_OF_UNIX_EPOCH

public static final java.lang.String BEGINNING_OF_UNIX_EPOCH
first day that can be set into a TimeTool

See Also:
Constant Field Values

END_OF_UNIX_EPOCH

public static final java.lang.String END_OF_UNIX_EPOCH
last date a TimeTool can be set to

See Also:
Constant Field Values

Monate

public static final java.lang.String[] Monate
Month names as full words


Mon

public static final java.lang.String[] Mon
Month names as three-letter-abbreviations


month_eng

public static final java.lang.String[] month_eng

wdays

public static final java.lang.String[] wdays
Weekdays as abbreviations


Wochentage

public static final java.lang.String[] Wochentage
weekdays as full words


FULL_GER

public static final int FULL_GER
Constant indicating a full date/time format in german notation (dd.MM.yyyyy hh:mm:ss)

See Also:
Constant Field Values

LARGE_GER

public static final int LARGE_GER
Constant indicating a large date/time format in german notation (dd.MM.yyyyy hh:mm)

See Also:
Constant Field Values

TIME_FULL

public static final int TIME_FULL
Constant indicating a full time format (hh:mm:ss)

See Also:
Constant Field Values

TIME_SMALL

public static final int TIME_SMALL
Constant indicating a small time format (hh:mm)

See Also:
Constant Field Values

DATE_GER

public static final int DATE_GER
Constant indicating a date in german notation (dd.mm.yy)

See Also:
Constant Field Values

FULL_MYSQL

public static final int FULL_MYSQL
Constant indicating a full date/time format in ISO notation (yyyyy-MM-dd hh:mm:ss)

See Also:
Constant Field Values

DATE_MYSQL

public static final int DATE_MYSQL
Constant indicating a date format in ISO notation (yyyyy-MM-dd)

See Also:
Constant Field Values

FULL_ISO

public static final int FULL_ISO
Constant indicating a full date/time format in ISO notation (yyyyy-MM-dd hh:mm:ss)

See Also:
Constant Field Values

DATE_ISO

public static final int DATE_ISO
Constant indicating a date format in ISO notation (yyyyy-MM-dd)

See Also:
Constant Field Values

TIME_COMPACT

public static final int TIME_COMPACT
Constant indicating a compact time format (hhmm)

See Also:
Constant Field Values

DATE_COMPACT

public static final int DATE_COMPACT
Constant indicating a compact date format (yyyyMMdd)

See Also:
Constant Field Values

FULL

public static final int FULL
Constant indicating a full date in the preferred format

See Also:
Constant Field Values

DATE_SIMPLE

public static final int DATE_SIMPLE
Constant indicating a simple date in the preferred format

See Also:
Constant Field Values

WEEKDAY

public static final int WEEKDAY
See Also:
Constant Field Values

TIMESTAMP

public static final int TIMESTAMP
Constant indicating a timestamp format (yyyyMMddhhmmss)

See Also:
Constant Field Values

DATETIME_XML

public static final int DATETIME_XML
Constant indicating an XML Datetime format (yyyy-MM-ddThh:mm:ss)

See Also:
Constant Field Values
Constructor Detail

TimeTool

public TimeTool()
create a TimeTool set to the current date/time


TimeTool

public TimeTool(TimeTool other)
Create a TimeTool set to another TimeTool's date/time

Parameters:
other - another TimeTool which will not be affected

TimeTool

public TimeTool(int t,
                int res)
Create a TimeTool set to the given units

Parameters:
t - number of units
res - multiplicator for the units in milliseconds

TimeTool

public TimeTool(java.lang.String pre)
Create a TimeTool set to a date/time as indicated by a String

Parameters:
pre - a date/time String in one of the supported formats. If the String can not be parsed, the TimeTool will be set to the current date/time

TimeTool

public TimeTool(java.lang.String pre,
                boolean bFailIfInvalid)
         throws TimeTool.TimeFormatException
Create a TimeTool set to a date/time as indicated by a String

Parameters:
pre - a date/time String in one of the supported formats.
bFailIfInvalid - true: Throw an Exception if pre cannot be parsed, false: set to current date/time
Throws:
TimeTool.TimeFormatException

TimeTool

public TimeTool(long millis)
Create a TimeTool set to the specified milliseconds

Parameters:
millis - Milliseconds after the epoch (same as System.getCirrentTimeMillis()
Method Detail

Version

public static java.lang.String Version()

getTimeInSeconds

public static int getTimeInSeconds()
return the time as seconds

Returns:
the seconds

getMinutesFromTimeString

public static int getMinutesFromTimeString(java.lang.String in)
Parse a String for time information and return these in minutes

Parameters:
in - a String formatted in one ofthe supported date/time formats
Returns:
the value of the String expressed as minutes

getSecondsFromTimeString

public static int getSecondsFromTimeString(java.lang.String in)
Parse a String for time information and return these in seconds

Parameters:
in - a String formatted in one ofthe supported date/time formats
Returns:
the value of the String expressed as seconds

set

public boolean set(java.lang.String orig)
Parsed einen String im Format "datum zeit" oder "datum, zeit" oder "datum" oder "zeit". Für datum sind folgende Formate gültig: yyyy-MM-dd, yy-MM-dd, dd.MM.yyyy, dd.MM.YY, yyyyMMdd für zeit sind folgende Formate gültig: hh:mm:ss, hh:mm, hhmm, hmm ausserdem das timestamp-format yyyyMMddhhmmss wenn datum gegeben ist, nicht aber Zeit, wird die Zeit auf 00:00:00 gesetzt wenn zeit gegeben ist, nicht aber Datum, wird das Datum nicht geändert


setDate

public boolean setDate(java.lang.String dat)
Set the date, leave the Time untouched

Parameters:
dat - the new dat
Returns:
true if dat could be parsed successfully

setDate

public void setDate(TimeTool o)
Set the date to the value of another TimeTool. Leave the time untouched

Parameters:
o - source that will be untouched

setTime

public void setTime(TimeTool o)
Set the time, leave the date untouched

Parameters:
o - a source tTimeTool that will not be changed

parseDate

public static int[] parseDate(java.lang.String tx)

parseTime

public static int[] parseTime(java.lang.String tx)
Zerlegt einen Zeitstring in Stunden- Minuten- und Sekundenanteile

Parameters:
tx -
Returns:
int[hr,min,s]

set

public void set(java.util.GregorianCalendar gcal)

set

public void set(TimeTool o)

setAsUnits

public void setAsUnits(int d)

secondsTo

public int secondsTo(TimeTool o)

daysTo

public int daysTo(TimeTool o)
Return the number of daysd between (including) this and (excluding) an other TimeTool

Parameters:
o - the other TimeTool
Returns:
the difference in days, counting positive if o is after this and negative else

setResolution

public void setResolution(long res)

diff

public long diff(TimeTool o,
                 long res)
Differenz zu einem anderen TimeTool, ausgedrückt in "resolution"-Einheiten

Parameters:
o - das andere TimeTool
res - die gewünschte Auflösung (in Millisekunden), oder 0, dann wird die Standard-resolution dieses TimeTools genommen
Returns:
die differenz, abgerundet auf "res"

isBeforeOrEqual

public boolean isBeforeOrEqual(TimeTool o)

isBefore

public boolean isBefore(TimeTool o)

isAfterOrEqual

public boolean isAfterOrEqual(TimeTool o)

isAfter

public boolean isAfter(TimeTool o)

isEqual

public boolean isEqual(TimeTool o)

isSameDay

public boolean isSameDay(TimeTool o)
Checks whether two TimeTool values represent the same day (ignoring the time)

Parameters:
o - the TimeTool to compare with
Returns:
true, if both times represent the same day

getTimeInUnits

public int getTimeInUnits()

getTimeAsLong

public long getTimeAsLong()

chop

public void chop(int w)
Inhalt kürzen.

Parameters:
w - 0: Millisekunden weg, 1: Sekunden, 2: Minuten, 3: Stunden

addUnits

public void addUnits(int m)

addDays

public void addDays(int d)

addMinutes

public void addMinutes(int m)

addHours

public void addHours(int h)

addSeconds

public void addSeconds(int s)

setDefaultResolution

public static void setDefaultResolution(int r)

setPreferredFormat

public static void setPreferredFormat(java.lang.String full,
                                      java.lang.String small,
                                      java.lang.String wr)

toDBString

public java.lang.String toDBString(boolean full)

toString

public java.lang.String toString()
Overrides:
toString in class java.util.Calendar

dump

public java.lang.String dump()

toString

public java.lang.String toString(int f)

hashCode

public int hashCode()
Overrides:
hashCode in class java.util.GregorianCalendar

minutesStringToInt

public static int minutesStringToInt(java.lang.String in)

compareTo

public int compareTo(java.util.Calendar arg0)
Specified by:
compareTo in interface java.lang.Comparable<java.util.Calendar>
Overrides:
compareTo in class java.util.Calendar

Elexis API documentation
Version 2.1.6 as of December 11 2011

Copyright 2005-2011 by Gerry Weirich, Elexis