org.kuali.rice.core.impl.datetime
Class DateTimeServiceImpl

java.lang.Object
  extended by org.kuali.rice.core.impl.datetime.DateTimeServiceImpl
All Implemented Interfaces:
DateTimeService, org.springframework.beans.factory.InitializingBean

public class DateTimeServiceImpl
extends Object
implements DateTimeService, org.springframework.beans.factory.InitializingBean

This class is the service implementation for a DateTime structure. This is the default, Kuali delivered implementation.


Field Summary
protected  String dateToStringFormatForFileName
           
protected  String dateToStringFormatForUserInterface
           
protected  String[] stringToDateFormats
           
protected  String[] stringToTimeFormats
           
protected  String[] stringToTimestampFormats
           
protected  String timestampToStringFormatForFileName
           
protected  String timestampToStringFormatForUserInterface
           
protected  String timeToStringFormatForUserInterface
           
 
Constructor Summary
DateTimeServiceImpl()
           
 
Method Summary
 void afterPropertiesSet()
          This overridden method ...
 Date convertToDate(String dateString)
          Formats strings into dates using the format string in the KR-NS/All/STRING_TO_DATE_FORMATS parameter
 Date convertToDateTime(String dateTimeString)
          Translates the specified string into a date with a time component, formatted according to "stringDateTimeFormat" that the service is configured with
 Date convertToSqlDate(String dateString)
          Converts the given String into a java.sql.Date instance
 Date convertToSqlDate(Timestamp timestamp)
          Converts a Timestamp into a sql Date.
 Time convertToSqlTime(String timeString)
          Converts the given String into a java.sql.Time instance
 Timestamp convertToSqlTimestamp(String timeString)
          Converts the given String into a java.sql.Timestamp instance according to the "stringDateTimeFormat" that the service is configured with
 int dateDiff(Date startDate, Date endDate, boolean inclusive)
          Returns the number of days between two days - start and end date of some arbitrary period.
 Calendar getCalendar(Date date)
          Returns a Calendar initialized to the given Date
 Calendar getCurrentCalendar()
          Returns a Calendar initialized with the current Date
 Date getCurrentDate()
          Returns the current date/time as a java.util.Date
 Date getCurrentSqlDate()
          Returns the current date/time as a java.sql.Date
 Date getCurrentSqlDateMidnight()
          Returns the current date as a java.sql.Date rounded back to midnight.
 Timestamp getCurrentTimestamp()
          Returns the current date/time as a java.sql.Timestamp
protected  Date parse(String dateString, String pattern)
           
protected  Date parseAgainstFormatArray(String dateString, String[] formats)
           
 String toDateString(Date date)
          Translates the specified date into a string without a time component, formatted according to "stringDateFormat" that the service is configured with
 String toDateStringForFilename(Date date)
          Returns a String representing a date that is suitable for file names, and is preferably chronologically sortable
 String toDateTimeString(Date date)
          Translates the specified date into a string with a time component, formatted according to the "stringDateTimeFormat" that the service is configured with
 String toDateTimeStringForFilename(Date date)
          Returns a String representing a date/time that is suitable for file names, and is preferably chronologically sortable
 String toString(Date date, String pattern)
          Translates the specified date into a string without a time component, formatted according to the specified pattern
 String toTimeString(Time time)
          Translates the specified time into a string without a date component, formatted according to "stringTimeFormat" that the service is configured with
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

stringToDateFormats

protected String[] stringToDateFormats

stringToTimeFormats

protected String[] stringToTimeFormats

stringToTimestampFormats

protected String[] stringToTimestampFormats

dateToStringFormatForUserInterface

protected String dateToStringFormatForUserInterface

timeToStringFormatForUserInterface

protected String timeToStringFormatForUserInterface

timestampToStringFormatForUserInterface

protected String timestampToStringFormatForUserInterface

dateToStringFormatForFileName

protected String dateToStringFormatForFileName

timestampToStringFormatForFileName

protected String timestampToStringFormatForFileName
Constructor Detail

DateTimeServiceImpl

public DateTimeServiceImpl()
Method Detail

toDateString

public String toDateString(Date date)
Description copied from interface: DateTimeService
Translates the specified date into a string without a time component, formatted according to "stringDateFormat" that the service is configured with

Specified by:
toDateString in interface DateTimeService
Returns:
formatted string version of the specified date
See Also:
DateTimeService.toDateString(java.util.Date)

toTimeString

public String toTimeString(Time time)
Description copied from interface: DateTimeService
Translates the specified time into a string without a date component, formatted according to "stringTimeFormat" that the service is configured with

Specified by:
toTimeString in interface DateTimeService
Returns:
formatted string version of the specified time
See Also:
DateTimeService.toTimeString(java.sql.Time)

toDateTimeString

public String toDateTimeString(Date date)
Description copied from interface: DateTimeService
Translates the specified date into a string with a time component, formatted according to the "stringDateTimeFormat" that the service is configured with

Specified by:
toDateTimeString in interface DateTimeService
Returns:
formatted string version of the specified date
See Also:
DateTimeService.toDateTimeString(java.util.Date)

toString

public String toString(Date date,
                       String pattern)
Description copied from interface: DateTimeService
Translates the specified date into a string without a time component, formatted according to the specified pattern

Specified by:
toString in interface DateTimeService
Returns:
formatted string version of the specified date
See Also:
DateTimeService.toString(java.util.Date, java.lang.String)

getCurrentDate

public Date getCurrentDate()
Description copied from interface: DateTimeService
Returns the current date/time as a java.util.Date

Specified by:
getCurrentDate in interface DateTimeService
Returns:
current date/time
See Also:
DateTimeService.getCurrentDate()

getCurrentTimestamp

public Timestamp getCurrentTimestamp()
Description copied from interface: DateTimeService
Returns the current date/time as a java.sql.Timestamp

Specified by:
getCurrentTimestamp in interface DateTimeService
Returns:
current date/time
See Also:
DateTimeService.getCurrentTimestamp()

getCurrentSqlDate

public Date getCurrentSqlDate()
Description copied from interface: DateTimeService
Returns the current date/time as a java.sql.Date

Specified by:
getCurrentSqlDate in interface DateTimeService
Returns:
current date/time
See Also:
DateTimeService.getCurrentSqlDate()

getCurrentSqlDateMidnight

public Date getCurrentSqlDateMidnight()
Description copied from interface: DateTimeService
Returns the current date as a java.sql.Date rounded back to midnight. This is what the JDBC driver is supposed to do with dates on their way to the database, so it can be convenient for comparing to dates from the database or input from the UI.

Specified by:
getCurrentSqlDateMidnight in interface DateTimeService
Returns:
current date at the most recent midnight in the JVM's timezone
See Also:
DateTimeService.getCurrentSqlDateMidnight()

getCurrentCalendar

public Calendar getCurrentCalendar()
Description copied from interface: DateTimeService
Returns a Calendar initialized with the current Date

Specified by:
getCurrentCalendar in interface DateTimeService
Returns:
currennt Calendar
See Also:
DateTimeService.getCurrentCalendar()

getCalendar

public Calendar getCalendar(Date date)
Description copied from interface: DateTimeService
Returns a Calendar initialized to the given Date

Specified by:
getCalendar in interface DateTimeService
Returns:
date-specific Calendar
See Also:
DateTimeService.getCalendar(java.util.Date)

convertToDate

public Date convertToDate(String dateString)
                   throws ParseException
Formats strings into dates using the format string in the KR-NS/All/STRING_TO_DATE_FORMATS parameter

Specified by:
convertToDate in interface DateTimeService
Returns:
the date representation of the specified dateString
Throws:
ParseException
See Also:
DateTimeService.convertToDate(java.lang.String)

convertToDateTime

public Date convertToDateTime(String dateTimeString)
                       throws ParseException
Description copied from interface: DateTimeService
Translates the specified string into a date with a time component, formatted according to "stringDateTimeFormat" that the service is configured with

Specified by:
convertToDateTime in interface DateTimeService
Returns:
the date representation of the specified dateTimeString
Throws:
ParseException
See Also:
DateTimeService.convertToDateTime(java.lang.String)

convertToSqlTimestamp

public Timestamp convertToSqlTimestamp(String timeString)
                                throws ParseException
Description copied from interface: DateTimeService
Converts the given String into a java.sql.Timestamp instance according to the "stringDateTimeFormat" that the service is configured with

Specified by:
convertToSqlTimestamp in interface DateTimeService
Returns:
java.sql.Timestamp
Throws:
ParseException - if the string cannot be converted
See Also:
DateTimeService.convertToSqlTimestamp(java.lang.String)

convertToSqlDate

public Date convertToSqlDate(String dateString)
                      throws ParseException
Description copied from interface: DateTimeService
Converts the given String into a java.sql.Date instance

Specified by:
convertToSqlDate in interface DateTimeService
Returns:
java.sql.Date
Throws:
ParseException - if the string cannot be converted
See Also:
DateTimeService.convertToSqlDate(java.lang.String)

convertToSqlTime

public Time convertToSqlTime(String timeString)
                      throws ParseException
Description copied from interface: DateTimeService
Converts the given String into a java.sql.Time instance

Specified by:
convertToSqlTime in interface DateTimeService
Returns:
java.sql.Time
Throws:
ParseException - if the string cannot be converted
See Also:
DateTimeService.convertToSqlTime(java.lang.String)

parseAgainstFormatArray

protected Date parseAgainstFormatArray(String dateString,
                                       String[] formats)
                                throws ParseException
Throws:
ParseException

convertToSqlDate

public Date convertToSqlDate(Timestamp timestamp)
                      throws ParseException
Description copied from interface: DateTimeService
Converts a Timestamp into a sql Date.

Specified by:
convertToSqlDate in interface DateTimeService
Returns:
Throws:
ParseException
See Also:
DateTimeService.convertToSqlDate(java.sql.Timestamp)

dateDiff

public int dateDiff(Date startDate,
                    Date endDate,
                    boolean inclusive)
Description copied from interface: DateTimeService
Returns the number of days between two days - start and end date of some arbitrary period.

Specified by:
dateDiff in interface DateTimeService
Parameters:
startDate - The first date in the period
endDate - The second date in the period
inclusive - Whether the result should include both the start and the end date. Otherwise it only includes one.
Returns:
int The number of days in the period

parse

protected Date parse(String dateString,
                     String pattern)
              throws ParseException
Throws:
ParseException

toDateStringForFilename

public String toDateStringForFilename(Date date)
Description copied from interface: DateTimeService
Returns a String representing a date that is suitable for file names, and is preferably chronologically sortable

Specified by:
toDateStringForFilename in interface DateTimeService
Returns:
See Also:
DateTimeService.toDateStringForFilename(java.util.Date)

toDateTimeStringForFilename

public String toDateTimeStringForFilename(Date date)
Description copied from interface: DateTimeService
Returns a String representing a date/time that is suitable for file names, and is preferably chronologically sortable

Specified by:
toDateTimeStringForFilename in interface DateTimeService
Returns:
See Also:
DateTimeService.toDateTimeStringForFilename(java.util.Date)

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
This overridden method ...

Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
Exception
See Also:
InitializingBean.afterPropertiesSet()


Copyright © 2005-2014 The Kuali Foundation. All Rights Reserved.