org.enblom.time
Interface DayDateFactory


public interface DayDateFactory

Factory for creating DayDate objects.

Author:
Andreas Enblom

Method Summary
 DayDate deserialize(String date)
          Creates a new DayDate object with date of the given string serialization, as returned by DayDate.serialize()
 DayDate fromInt(int date)
          Converts an int, as returned from DayDate.toInt() to a DayDate object.
 DayDate getDefault()
          Returns a default date value: 1970-01-01 (the UNIX epoch date).
 DayDate now()
           
 DayDate parse(int year, int month, int day)
          Creates a new DayDate object, if possible, from the given parameters.
 DayDate parse(String date)
          Creates a new DayDate object, if possible, from the given string representation.
 DayDate parse(String year, String month, String day)
          Creates a new DayDate object, if possible, from the given parameters.
 DayDate utc()
           
 

Method Detail

now

DayDate now()
Returns:
The current date in the default timezone.

utc

DayDate utc()
Returns:
The current date in the UTC timezone.

getDefault

DayDate getDefault()
Returns a default date value: 1970-01-01 (the UNIX epoch date). This is useful instead of null values.

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

deserialize

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

Parameters:
date - The string serialization of the date, on the format YYYYMMDD.
Returns:
The deserialized day date object.
Throws:
IllegalArgumentException - If the given string serialization does not represent a correct date.

parse

DayDate parse(String year,
              String month,
              String day)
Creates a new DayDate object, if possible, from the given parameters. If the given parameters do not represent a date, 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.
Returns:
The date object, or null if the provided parameters do not represent a correct date.

parse

DayDate parse(int year,
              int month,
              int day)
Creates a new DayDate object, if possible, from the given parameters. If the given parameters do not represent a date, 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.
Returns:
The date object, or null if the provided parameters do not represent a correct date.

parse

DayDate parse(String date)
Creates a new DayDate object, if possible, from the given string representation. If the given representation do not represent a date, null is returned.

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

fromInt

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

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


Copyright © 2013. All Rights Reserved.