org.enblom.time
Interface TimeFactory


public interface TimeFactory

Factory for creating Time objects.

Author:
Andreas Enblom

Method Summary
 Time create(DayDate date, TimeOfDay timeOfDay)
          Creates a new Time instance representing the given time of day of the given date.
 Time deserialize(String time)
          Creates a new Time object with time of the given string serialization, as returned by Time.serialize()
 Time fromJavaUtilDate(Date date)
          Converts a Date to a Time object, using the default time zone.
 Time fromJavaUtilDate(Date date, TimeZone timeZone)
          Converts a Date to a Time object, using the given time zone.
 Time fromLong(long time)
          Converts a long, as returned from Time.toLong() to a Time object.
 Time getDefault()
          Returns a default time value: 1970-01-01 00:00:00.000 (the UNIX epoch time).
 Time now()
           
 Time parse(DayDate date, int hour, int minute, int second)
          Creates a new Time object, if possible, from the given parameters.
 Time parse(DayDate date, int hour, int minute, int second, int millis)
          Creates a new Time object, if possible, from the given parameters.
 Time parse(DayDate date, String hour, String minute, String second)
          Creates a new Time object, if possible, from the given parameters.
 Time parse(DayDate date, String hour, String minute, String second, String millis)
          Creates a new Time object, if possible, from the given parameters.
 Time parse(int year, int month, int day, int hour, int minute, int second)
          Creates a new Time object, if possible, from the given parameters.
 Time parse(int year, int month, int day, int hour, int minute, int second, int millis)
          Creates a new Time object, if possible, from the given parameters.
 Time parse(String time)
          Creates a new Time object, if possible, from the given representation.
 Time parse(String date, int hour, int minute, int second)
          Creates a new Time object, if possible, from the given parameters.
 Time parse(String date, int hour, int minute, int second, int millis)
          Creates a new Time object, if possible, from the given parameters.
 Time parse(String date, String hour, String minute, String second)
          Creates a new Time object, if possible, from the given parameters.
 Time parse(String date, String hour, String minute, String second, String millis)
          Creates a new Time object, if possible, from the given parameters.
 Time parse(String year, String month, String day, String hour, String minute, String second)
          Creates a new Time object, if possible, from the given parameters.
 Time parse(String year, String month, String day, String hour, String minute, String second, String millis)
          Creates a new Time object, if possible, from the given parameters.
 Time parse(String date, TimeOfDay timeOfDay)
          Creates a new Time object, if possible, from the given parameters.
 Time unpack(long time)
          Converts a long, as returned from Time.pack() to a Time object.
 Time utc()
           
 

Method Detail

now

Time now()
Returns:
The current time in the default timezone.

utc

Time utc()
Returns:
The current time in the UTC timezone.

getDefault

Time getDefault()
Returns a default time value: 1970-01-01 00:00:00.000 (the UNIX epoch time). This is useful instead of null values.

Returns:
The default time: 1970-01-01 00:00:00.000.

create

Time create(DayDate date,
            TimeOfDay timeOfDay)
Creates a new Time instance representing the given time of day of the given date.

Parameters:
date - The date.
timeOfDay - The time of day.
Returns:
The new instance.

deserialize

Time deserialize(String time)
                 throws IllegalArgumentException
Creates a new Time object with time of the given string serialization, as returned by Time.serialize()

Parameters:
time - The string serialization of the time, on the format YYYYMMDDhhmmssnnn, where nnn is the milliseconds.
Returns:
The deserialized time object.
Throws:
IllegalArgumentException - If the given string serialization does not represent a correct timestamp.

parse

Time parse(String year,
           String month,
           String day,
           String hour,
           String minute,
           String second)
Creates a new Time object, if possible, from the given parameters. If the given parameters do not represent a correct time, null is returned. This is the case even if the parameters are totally wrong (i.e. not number, out of range, null etc etc) - no exception is ever thrown.

The millisecond of the time is set to 0.

Parameters:
year - The year in the range 1000-9999.
month - The month in the range 1-12.
day - The day in the range 1-28, 1-29, 1-30 or 1-31 depending on month and year.
hour - The hour in the range 0-23.
minute - The minute in the range 0-59.
second - The second in the range 0-59.
Returns:
The time object, or null if the provided parameters do not represent a correct time.

parse

Time parse(int year,
           int month,
           int day,
           int hour,
           int minute,
           int second)
Creates a new Time object, if possible, from the given parameters. If the given parameters do not represent a correct time, null is returned. This is the case even if the parameters are totally wrong (i.e. out of range, null etc etc) - no exception is ever thrown.

The millisecond of the time is set to 0.

Parameters:
year - The year in the range 1000-9999.
month - The month in the range 1-12.
day - The day in the range 1-28, 1-29, 1-30 or 1-31 depending on month and year.
hour - The hour in the range 0-23.
minute - The minute in the range 0-59.
second - The second in the range 0-59.
Returns:
The time object, or null if the provided parameters do not represent a correct time.

parse

Time parse(String year,
           String month,
           String day,
           String hour,
           String minute,
           String second,
           String millis)
Creates a new Time object, if possible, from the given parameters. If the given parameters do not represent a correct time, null is returned. This is the case even if the parameters are totally wrong (i.e. not number, out of range, null etc etc) - no exception is ever thrown.

Parameters:
year - The year in the range 1000-9999.
month - The month in the range 1-12.
day - The day in the range 1-28, 1-29, 1-30 or 1-31 depending on month and year.
hour - The hour in the range 0-23.
minute - The minute in the range 0-59.
second - The second in the range 0-59.
millis - The millisecond in the range 0-999.
Returns:
The time object, or null if the provided parameters do not represent a correct time.

parse

Time parse(int year,
           int month,
           int day,
           int hour,
           int minute,
           int second,
           int millis)
Creates a new Time object, if possible, from the given parameters. If the given parameters do not represent a correct time, null is returned. This is the case even if the parameters are totally wrong (i.e. out of range, null etc etc) - no exception is ever thrown.

Parameters:
year - The year in the range 1000-9999.
month - The month in the range 1-12.
day - The day in the range 1-28, 1-29, 1-30 or 1-31 depending on month and year.
hour - The hour in the range 0-23.
minute - The minute in the range 0-59.
second - The second in the range 0-59.
millis - The millisecond in the range 0-999.
Returns:
The time object, or null if the provided parameters do not represent a correct time.

parse

Time parse(String date,
           String hour,
           String minute,
           String second)
Creates a new Time object, if possible, from the given parameters. If the given parameters do not represent a correct time, null is returned. This is the case even if the parameters are totally wrong (i.e. not number, out of range, null etc etc) - no exception is ever thrown.

The millisecond of the time is set to 0.

Parameters:
date - The date, represented as a string on one of the formats YYYYMMDD and YYYY-MM-DD.
hour - The hour in the range 0-23.
minute - The minute in the range 0-59.
second - The second in the range 0-59.
Returns:
The time object, or null if the provided parameters do not represent a correct time.

parse

Time parse(String date,
           int hour,
           int minute,
           int second)
Creates a new Time object, if possible, from the given parameters. If the given parameters do not represent a correct time, null is returned. This is the case even if the parameters are totally wrong (i.e. not number, out of range, null etc etc) - no exception is ever thrown.

The millisecond of the time is set to 0.

Parameters:
date - The date, represented as a string on one of the formats YYYYMMDD and YYYY-MM-DD.
hour - The hour in the range 0-23.
minute - The minute in the range 0-59.
second - The second in the range 0-59.
Returns:
The time object, or null if the provided parameters do not represent a correct time.

parse

Time parse(String date,
           String hour,
           String minute,
           String second,
           String millis)
Creates a new Time object, if possible, from the given parameters. If the given parameters do not represent a correct time, null is returned. This is the case even if the parameters are totally wrong (i.e. not number, out of range, null etc etc) - no exception is ever thrown.

Parameters:
date - The date, represented as a string on one of the formats YYYYMMDD and YYYY-MM-DD.
hour - The hour in the range 0-23.
minute - The minute in the range 0-59.
second - The second in the range 0-59.
millis - The millisecond in the range 0-999.
Returns:
The time object, or null if the provided parameters do not represent a correct time.

parse

Time parse(String date,
           int hour,
           int minute,
           int second,
           int millis)
Creates a new Time object, if possible, from the given parameters. If the given parameters do not represent a correct time, null is returned. This is the case even if the parameters are totally wrong (i.e. not number, out of range, null etc etc) - no exception is ever thrown.

Parameters:
date - The date, represented as a string on one of the formats YYYYMMDD and YYYY-MM-DD.
hour - The hour in the range 0-23.
minute - The minute in the range 0-59.
second - The second in the range 0-59.
millis - The millisecond in the range 0-999.
Returns:
The time object, or null if the provided parameters do not represent a correct time.

parse

Time parse(String date,
           TimeOfDay timeOfDay)
Creates a new Time object, if possible, from the given parameters. If the given parameters do not represent a correct time, null is returned. This is the case even if the parameters are totally wrong (i.e. not number, out of range, null etc etc) - no exception is ever thrown.

Parameters:
date - The date, represented as a string on one of the formats YYYYMMDD and YYYY-MM-DD.
timeOfDay - The time of day.
Returns:
The time object, or null if the provided parameters do not represent a correct time.

parse

Time parse(DayDate date,
           String hour,
           String minute,
           String second)
Creates a new Time object, if possible, from the given parameters. If the given parameters do not represent a correct time, null is returned. This is the case even if the parameters are totally wrong (i.e. not number, out of range, null etc etc) - no exception is ever thrown.

The millisecond is set to 0.

Parameters:
date - The date.
hour - The hour in the range 0-23.
minute - The minute in the range 0-59.
second - The second in the range 0-59.
Returns:
The time object, or null if the provided parameters do not represent a correct time.

parse

Time parse(DayDate date,
           int hour,
           int minute,
           int second)
Creates a new Time object, if possible, from the given parameters. If the given parameters do not represent a correct time, null is returned. This is the case even if the parameters are totally wrong (i.e. out of range, null etc etc) - no exception is ever thrown.

The millisecond is set to 0.

Parameters:
date - The date.
hour - The hour in the range 0-23.
minute - The minute in the range 0-59.
second - The second in the range 0-59.
Returns:
The time object, or null if the provided parameters do not represent a correct time.

parse

Time parse(DayDate date,
           String hour,
           String minute,
           String second,
           String millis)
Creates a new Time object, if possible, from the given parameters. If the given parameters do not represent a correct time, null is returned. This is the case even if the parameters are totally wrong (i.e. not number, out of range, null etc etc) - no exception is ever thrown.

Parameters:
date - The date.
hour - The hour in the range 0-23.
minute - The minute in the range 0-59.
second - The second in the range 0-59.
millis - The millisecond in the range 0-999.
Returns:
The time object, or null if the provided parameters do not represent a correct time.

parse

Time parse(DayDate date,
           int hour,
           int minute,
           int second,
           int millis)
Creates a new Time object, if possible, from the given parameters. If the given parameters do not represent a correct time, null is returned. This is the case even if the parameters are totally wrong (i.e. out of range, null etc etc) - no exception is ever thrown.

Parameters:
date - The date.
hour - The hour in the range 0-23.
minute - The minute in the range 0-59.
second - The second in the range 0-59.
millis - The millisecond in the range 0-999.
Returns:
The time object, or null if the provided parameters do not represent a correct time.

parse

Time parse(String time)
Creates a new Time object, if possible, from the given representation. If the given representation do not represent a correct time, null is returned. This is the case even if the representation is totally wrong - no exception is ever thrown.

Parameters:
time - The timestamp, in the format date time, where date is on one of the formats YYYYMMDD and YYYY-MM-DD, and time is on one of the formats hhmmss, hhmmssnnn, hh:mm:ss, hh:mm:ss.nnn, where nnn is the millisecond.
Returns:
The time object, or null if the provided paramater does not represent a correct time.

fromJavaUtilDate

Time fromJavaUtilDate(Date date)
Converts a Date to a Time object, using the default time zone.

Parameters:
date - The date to convert.
Returns:
The converted time.

fromJavaUtilDate

Time fromJavaUtilDate(Date date,
                      TimeZone timeZone)
Converts a Date to a Time object, using the given time zone.

Parameters:
date - The date to convert.
timeZone - The time zone, or null to use the default time zone.
Returns:
The converted time.

fromLong

Time fromLong(long time)
              throws IllegalArgumentException
Converts a long, as returned from Time.toLong() to a Time object.

Parameters:
time - The long value.
Returns:
The converted time.
Throws:
IllegalArgumentException - If the given long value does not correctly represent a time.

unpack

Time unpack(long time)
            throws IllegalArgumentException
Converts a long, as returned from Time.pack() to a Time object.

Parameters:
time - The long value.
Returns:
The converted time.
Throws:
IllegalArgumentException - If the given long value does not correctly represent a time.


Copyright © 2013. All Rights Reserved.