com.gisgraphy.util
Class DateUtil

java.lang.Object
  extended by com.gisgraphy.util.DateUtil

public class DateUtil
extends 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).

Method Summary
static String convertDateToString(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 Date convertStringToDate(String strDate)
          This method converts a String to a date using the datePattern
static Date convertStringToDate(String aMask, String strDate)
          This method generates a string representation of a date/time in the format you specify on input
static String getDate(Date aDate)
          This method attempts to convert an Oracle-formatted date in the form dd-MMM-yyyy to mm/dd/yyyy.
static String getDatePattern()
          Return default datePattern (MM/dd/yyyy)
static String getDateTime(String aMask, Date aDate)
          This method generates a string representation of a date's date/time in the format you specify on input
static String getDateTimePattern()
           
static String getTimeNow(Date theTime)
          This method returns the current date time in the format: MM/dd/yyyy HH:MM a
static 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
 

Method Detail

getDatePattern

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

Returns:
a string representing the date pattern on the UI

getDateTimePattern

public static String getDateTimePattern()

getDate

public static String getDate(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 Date convertStringToDate(String aMask,
                                       String strDate)
                                throws 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:
ParseException - when String doesn't match the expected format
See Also:
SimpleDateFormat

getTimeNow

public static String getTimeNow(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 Calendar getToday()
                         throws ParseException
This method returns the current date in the format: MM/dd/yyyy

Returns:
the current date
Throws:
ParseException - when String doesn't match the expected format

getDateTime

public static String getDateTime(String aMask,
                                 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 String convertDateToString(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 Date convertStringToDate(String strDate)
                                throws 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:
ParseException - when String doesn't match the expected format


Copyright © 2012. All Rights Reserved.