org.appfuse.util
Class DateUtil

java.lang.Object
  extended by org.appfuse.util.DateUtil

public class DateUtil
extends java.lang.Object

Date Utility Class used to convert Strings to Dates and Timestamps

Author:
Matt Raible Modified by Dan Kibler to correct time pattern. Minutes should be mm not MM (MM is month).

Constructor Summary
DateUtil()
           
 
Method Summary
static java.lang.String convertDateToString(java.util.Date aDate)
          This method generates a string representation of a date based on the System Property 'dateFormat' in the format you specify on input
static java.util.Date convertStringToDate(java.lang.String strDate)
          This method converts a String to a date using the datePattern
static java.util.Date convertStringToDate(java.lang.String aMask, java.lang.String strDate)
          This method generates a string representation of a date/time in the format you specify on input
static java.lang.String getDate(java.util.Date aDate)
          This method attempts to convert an Oracle-formatted date in the form dd-MMM-yyyy to mm/dd/yyyy.
static java.lang.String getDatePattern()
          Return default datePattern (MM/dd/yyyy)
static java.lang.String getDateTime(java.lang.String aMask, java.util.Date aDate)
          This method generates a string representation of a date's date/time in the format you specify on input
static java.lang.String getDateTimePattern()
           
static java.lang.String getTimeNow(java.util.Date theTime)
          This method returns the current date time in the format: MM/dd/yyyy HH:MM a
static java.util.Calendar getToday()
          This method returns the current date in the format: MM/dd/yyyy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateUtil

public DateUtil()
Method Detail

getDatePattern

public static java.lang.String getDatePattern()
Return default datePattern (MM/dd/yyyy)

Returns:
a string representing the date pattern on the UI

getDateTimePattern

public static java.lang.String getDateTimePattern()

getDate

public static java.lang.String getDate(java.util.Date aDate)
This method attempts to convert an Oracle-formatted date in the form dd-MMM-yyyy to mm/dd/yyyy.

Parameters:
aDate - date from database as a string
Returns:
formatted string for the ui

convertStringToDate

public static java.util.Date convertStringToDate(java.lang.String aMask,
                                                 java.lang.String strDate)
                                          throws java.text.ParseException
This method generates a string representation of a date/time in the format you specify on input

Parameters:
aMask - the date pattern the string is in
strDate - a string representation of a date
Returns:
a converted Date object
Throws:
java.text.ParseException
See Also:
SimpleDateFormat

getTimeNow

public static java.lang.String getTimeNow(java.util.Date theTime)
This method returns the current date time in the format: MM/dd/yyyy HH:MM a

Parameters:
theTime - the current time
Returns:
the current date/time

getToday

public static java.util.Calendar getToday()
                                   throws java.text.ParseException
This method returns the current date in the format: MM/dd/yyyy

Returns:
the current date
Throws:
java.text.ParseException

getDateTime

public static java.lang.String getDateTime(java.lang.String aMask,
                                           java.util.Date aDate)
This method generates a string representation of a date's date/time in the format you specify on input

Parameters:
aMask - the date pattern the string is in
aDate - a date object
Returns:
a formatted string representation of the date
See Also:
SimpleDateFormat

convertDateToString

public static java.lang.String convertDateToString(java.util.Date aDate)
This method generates a string representation of a date based on the System Property 'dateFormat' in the format you specify on input

Parameters:
aDate - A date to convert
Returns:
a string representation of the date

convertStringToDate

public static java.util.Date convertStringToDate(java.lang.String strDate)
                                          throws java.text.ParseException
This method converts a String to a date using the datePattern

Parameters:
strDate - the date to convert (in format MM/dd/yyyy)
Returns:
a date object
Throws:
java.text.ParseException


Copyright © 2003-2007. All Rights Reserved.