org.archiviststoolkit.util
Class ATDateUtils

java.lang.Object
  extended by org.archiviststoolkit.util.ATDateUtils

public class ATDateUtils
extends java.lang.Object

Archivists' Toolkit(TM) Copyright 2005-2007 Regents of the University of California, New York University, & Five Colleges, Inc. All rights reserved. This software is free. You can redistribute it and / or modify it under the terms of the Educational Community License (ECL) version 1.0 (http://www.opensource.org/licenses/ecl1.php) This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ECL license for more details about permissions and limitations. Archivists' Toolkit(TM) http://www.archiviststoolkit.org info@archiviststoolkit.org Simple utility class for checking that an entered date is valid for the given database and for handeling iso dates in the AT Created by IntelliJ IDEA. User: Nathan Stevens Date: Aug 28, 2008 Time: 10:46:58 AM To change this template use File | Settings | File Templates.


Field Summary
static long MICROSOFT_SQL_SERVER_MINDATE
           
static long MYSQL_MINDATE
           
 
Constructor Summary
ATDateUtils()
           
 
Method Summary
static java.lang.String formatISODate(java.lang.String date)
          Method to format an inputed date to the iso format of either yyyy, yyyy-mm, or yyyy-mm-dd
static java.lang.Long getISODateInSeconds(java.lang.String isoDate)
          Method to get an iso date in the format yyyy, yyyy-mm, or yyyy-mm-dd in GMT seconds
static java.lang.Integer getYearFromISODate(java.lang.String isoDate)
          Method to return the year part from an iso date in either yyyy, yyyy-mm, or yyyy-mm-dd
static boolean isValidATDate(javax.swing.JTextField textField)
          Method to check to see if the text in the textfield is a valid date.
static void isValidDatabaseDate(javax.swing.JFormattedTextField textField)
          Method to check to see if a textField as a date that can be
static boolean isValidISODate(javax.swing.JTextField textField)
          Method to check to see if the string that was passed in is a valid iso date.
static java.lang.String padMonthOrDay(java.lang.String mod)
          Pad the month or day with a leading zero
static java.lang.String padYear(java.lang.String year)
          Method to pad the given year with leading zero
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MYSQL_MINDATE

public static final long MYSQL_MINDATE
See Also:
Constant Field Values

MICROSOFT_SQL_SERVER_MINDATE

public static final long MICROSOFT_SQL_SERVER_MINDATE
See Also:
Constant Field Values
Constructor Detail

ATDateUtils

public ATDateUtils()
Method Detail

isValidDatabaseDate

public static void isValidDatabaseDate(javax.swing.JFormattedTextField textField)
Method to check to see if a textField as a date that can be

Parameters:
textField -

isValidATDate

public static boolean isValidATDate(javax.swing.JTextField textField)
Method to check to see if the text in the textfield is a valid date.

Parameters:
textField - The text field

isValidISODate

public static boolean isValidISODate(javax.swing.JTextField textField)
Method to check to see if the string that was passed in is a valid iso date. valid iso dates can be either yyyy, yyyy-mm, yyyy-mm-dd

Parameters:
textField - The textfield containing the iso date to check
Returns:
true if the date passes the check for an iso date

formatISODate

public static java.lang.String formatISODate(java.lang.String date)
Method to format an inputed date to the iso format of either yyyy, yyyy-mm, or yyyy-mm-dd

Parameters:
date - The input date to format
Returns:
The formated iso date

padYear

public static java.lang.String padYear(java.lang.String year)
Method to pad the given year with leading zero

Parameters:
year - The year that is pasted in
Returns:
The year paded with zero or an empty string if not a valid year

padMonthOrDay

public static java.lang.String padMonthOrDay(java.lang.String mod)
Pad the month or day with a leading zero

Parameters:
mod - The month or day to pad
Returns:
The padded month or day or a blank string if not a valid day or year

getYearFromISODate

public static java.lang.Integer getYearFromISODate(java.lang.String isoDate)
Method to return the year part from an iso date in either yyyy, yyyy-mm, or yyyy-mm-dd

Parameters:
isoDate -
Returns:
the year from an iso date

getISODateInSeconds

public static java.lang.Long getISODateInSeconds(java.lang.String isoDate)
Method to get an iso date in the format yyyy, yyyy-mm, or yyyy-mm-dd in GMT seconds

Parameters:
isoDate - The isodate to convert to seconds
Returns:
GMT Seconds representing the given date