org.enblom.time
Interface TimeOfDayFactory


public interface TimeOfDayFactory

Factory for creating TimeOfDay objects.

Author:
Andreas Enblom

Method Summary
 TimeOfDay deserialize(String time)
          Creates a new TimeOfDay object with time of the given string serialization, as returned by TimeOfDay.serialize()
 TimeOfDay fromInt(int time)
          Converts an int, as returned from TimeOfDay.toInt() to a TimeOfDay object.
 TimeOfDay getDefault()
          Returns a default time of day: 00:00:00.000 (midnight).
 TimeOfDay now()
           
 TimeOfDay parse(int hour, int minute, int second)
          Creates a new TimeOfDay object, if possible, from the given parameters.
 TimeOfDay parse(int hour, int minute, int second, int millis)
          Creates a new TimeOfDay object, if possible, from the given parameters.
 TimeOfDay parse(String timeOfDay)
          Creates a new TimeOfDay object, if possible, from the given string representation.
 TimeOfDay parse(String hour, String minute, String second)
          Creates a new TimeOfDay object, if possible, from the given parameters.
 TimeOfDay parse(String hour, String minute, String second, String millis)
          Creates a new TimeOfDay object, if possible, from the given parameters.
 TimeOfDay utc()
           
 

Method Detail

now

TimeOfDay now()
Returns:
The current time of day in the default timezone.

utc

TimeOfDay utc()
Returns:
The current time of day in the UTC timezone.

getDefault

TimeOfDay getDefault()
Returns a default time of day: 00:00:00.000 (midnight). This is useful instead of null values.

Returns:
The default time of day: 00:00:00.000.

deserialize

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

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

parse

TimeOfDay parse(String hour,
                String minute,
                String second)
Creates a new TimeOfDay object, if possible, from the given parameters. If the given parameters do not represent a correct time of day, 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:
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 of day object, or null if the provided parameters do not represent a correct time.

parse

TimeOfDay parse(int hour,
                int minute,
                int second)
Creates a new TimeOfDay object, if possible, from the given parameters. If the given parameters do not represent a correct time of day, 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:
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 of day object, or null if the provided parameters do not represent a correct time.

parse

TimeOfDay parse(String hour,
                String minute,
                String second,
                String millis)
Creates a new TimeOfDay object, if possible, from the given parameters. If the given parameters do not represent a correct time of day, 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:
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 of day object, or null if the provided parameters do not represent a correct time.

parse

TimeOfDay parse(int hour,
                int minute,
                int second,
                int millis)
Creates a new TimeOfDay object, if possible, from the given parameters. If the given parameters do not represent a correct time of day, 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:
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 of day object, or null if the provided parameters do not represent a correct time.

parse

TimeOfDay parse(String timeOfDay)
Creates a new TimeOfDay object, if possible, from the given string representation. If the given representation do not represent a correct time of day, null is returned.

If a millisecond value is not provided in the given string representation, the millisecond is set to 0.

Parameters:
timeOfDay - The time, represented as a string on one of the formats hhmmss, hhmmssnnn, hh:mm:ss, hh:mm:ss.nnn, where nnn is the millisecond.
Returns:
The time of day object, or null if the provided string representation does not represent a correct time of day.

fromInt

TimeOfDay fromInt(int time)
                  throws IllegalArgumentException
Converts an int, as returned from TimeOfDay.toInt() to a TimeOfDay object.

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


Copyright © 2013. All Rights Reserved.