fedora.server.utilities
Class DateUtility

java.lang.Object
  extended byfedora.server.utilities.DateUtility

public abstract class DateUtility
extends java.lang.Object

Title: DateUtility.java

Description: A collection of utility methods for performing

frequently require tasks.

-----------------------------------------------------------------------------

License and Copyright: The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/.

Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License.

The entire file consists of original code. Copyright © 2002-2005 by The Rector and Visitors of the University of Virginia and Cornell University. All rights reserved.

-----------------------------------------------------------------------------

Version:
$Id: DateUtility.java,v 1.19 2005/01/12 22:33:49 payette Exp $
Author:
rlw@virginia.edu

Constructor Summary
DateUtility()
           
 
Method Summary
static java.lang.String convertDateToString(java.util.Date date)
          Converts an instance of java.util.Date into a String using the date format: yyyy-MM-ddTHH:mm:ss.SSSZ.
static java.util.Date convertLocalDateToUTCDate(java.util.Date localDate)
           
static java.util.Date convertStringToDate(java.lang.String dateTime)
          Converts a datetime string into and instance of java.util.Date using the date format: yyyy-MM-ddTHH:mm:ss.SSSZ.
static void main(java.lang.String[] args)
           
static java.util.Date parseDate(java.lang.String str)
          Attempt to parse the given string of form: yyyy-MM-dd[THH:mm:ss[.SSS][Z]] as a Date.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateUtility

public DateUtility()
Method Detail

convertStringToDate

public static java.util.Date convertStringToDate(java.lang.String dateTime)

Converts a datetime string into and instance of java.util.Date using the date format: yyyy-MM-ddTHH:mm:ss.SSSZ.

Follows Postel's Law (lenient about what it accepts, as long as it's sensible)

Parameters:
dateTime - A datetime string
Returns:
Corresponding instance of java.util.Date (returns null if dateTime string argument is empty string or null)

convertDateToString

public static java.lang.String convertDateToString(java.util.Date date)

Converts an instance of java.util.Date into a String using the date format: yyyy-MM-ddTHH:mm:ss.SSSZ.

Parameters:
date - Instance of java.util.Date.
Returns:
Corresponding datetime string (returns null if Date argument is null).

convertLocalDateToUTCDate

public static java.util.Date convertLocalDateToUTCDate(java.util.Date localDate)

parseDate

public static java.util.Date parseDate(java.lang.String str)
Attempt to parse the given string of form: yyyy-MM-dd[THH:mm:ss[.SSS][Z]] as a Date. If the string is not of that form, return null.

Parameters:
str - the date string to parse
Returns:
Date the date, if parse was successful; null otherwise

main

public static void main(java.lang.String[] args)