org.dspace.content
Class DCDate

java.lang.Object
  extended by org.dspace.content.DCDate

public class DCDate
extends Object

Dublin Core date utility class

Dates in the DSpace database are held in the ISO 8601 format. They are always stored in UTC, converting to and from the current time zone.

YYYY-MM-DDThh:mm:ss

There are four levels of granularity, depending on how much date information is available.

Examples: 1994-05-03T15:30:24,1995-10-04, 2001-10,1975

Version:
$Revision: 1947 $
Author:
Robert Tansley

Constructor Summary
DCDate()
          Construct a clean date
DCDate(Date date)
          Construct a date object from a Java Date object.
DCDate(String fromDC)
          Construct a date from a Dublin Core value
 
Method Summary
static DCDate getCurrent()
          Get a date representing the current instant in time.
 int getDay()
          Get the day, adjusting for current time zone.
 int getDayGMT()
          Get the day in GMT.
 int getHour()
          Get the hour, adjusting for current time zone.
 int getHourGMT()
          Get the hour in GMT.
 int getMinute()
          Get the minute, adjusting for current time zone.
 int getMinuteGMT()
          Get the minute in GMT.
 int getMonth()
          Get the month, adjusting for current time zone.
 int getMonthGMT()
          Get the month in GMT.
static String getMonthName(int m, Locale locale)
          Get a month's name for a month between 1 and 12.
 int getSecond()
          Get the second, adjusting for current time zone.
 int getSecondGMT()
          Get the second in GMT.
 int getYear()
          Get the year, adjusting for current time zone.
 int getYearGMT()
          Get the year in GMT.
 void setDateLocal(int yyyy, int mm, int dd, int hh, int mn, int ss)
          Set the date.
 Date toDate()
          Get the date as a Java Date object
 String toString()
          Get the date as a string to put back in the Dublin Core
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DCDate

public DCDate()
Construct a clean date


DCDate

public DCDate(String fromDC)
Construct a date from a Dublin Core value

Parameters:
fromDC - the date string, in ISO 8601 (no timezone, always use UTC/GMT)

DCDate

public DCDate(Date date)
Construct a date object from a Java Date object.

Parameters:
date - the Java Date object.
Method Detail

getCurrent

public static DCDate getCurrent()
Get a date representing the current instant in time.

Returns:
a DSpaceDate object representing the current instant.

toString

public String toString()
Get the date as a string to put back in the Dublin Core

Overrides:
toString in class Object
Returns:
The date as a string.

toDate

public Date toDate()
Get the date as a Java Date object

Returns:
a Date object

setDateLocal

public void setDateLocal(int yyyy,
                         int mm,
                         int dd,
                         int hh,
                         int mn,
                         int ss)
Set the date. The date passed in is assumed to be in the current time zone, and is adjusting to fit the current time zone. Unknown values should be given as -1.

Parameters:
yyyy - the year
mm - the month
dd - the day
hh - the hours
mn - the minutes
ss - the seconds

getYear

public int getYear()
Get the year, adjusting for current time zone.

Returns:
the year

getMonth

public int getMonth()
Get the month, adjusting for current time zone.

Returns:
the month

getDay

public int getDay()
Get the day, adjusting for current time zone.

Returns:
the day

getHour

public int getHour()
Get the hour, adjusting for current time zone.

Returns:
the hour

getMinute

public int getMinute()
Get the minute, adjusting for current time zone.

Returns:
the minute

getSecond

public int getSecond()
Get the second, adjusting for current time zone.

Returns:
the second

getYearGMT

public int getYearGMT()
Get the year in GMT.

Returns:
the year

getMonthGMT

public int getMonthGMT()
Get the month in GMT.

Returns:
the month

getDayGMT

public int getDayGMT()
Get the day in GMT.

Returns:
the day

getHourGMT

public int getHourGMT()
Get the hour in GMT.

Returns:
the hour

getMinuteGMT

public int getMinuteGMT()
Get the minute in GMT.

Returns:
the minute

getSecondGMT

public int getSecondGMT()
Get the second in GMT.

Returns:
the second

getMonthName

public static String getMonthName(int m,
                                  Locale locale)
Get a month's name for a month between 1 and 12. Any invalid month value (e.g. 0 or -1) will return a value of "Unspecified".

Parameters:
m - the month number
Returns:
the month name.


Copyright © 2008 The DSpace Foundation. All Rights Reserved.