org.kuali.rice.core.api.datetime
Interface DateTimeService

All Known Implementing Classes:
DateTimeServiceImpl

public interface DateTimeService

This interface defines methods that a DateTime service must provide


Method Summary
 Date convertToDate(String dateString)
          Translates the specified string into a date without a time component, see implementation class for formatting details
 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.
 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 date1, Date date2, 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
 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
 

Method Detail

toDateString

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

Parameters:
date -
Returns:
formatted string version of the specified date

toDateTimeString

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

Parameters:
date -
Returns:
formatted string version of the specified date

toString

String toString(Date date,
                String pattern)
Translates the specified date into a string without a time component, formatted according to the specified pattern

Parameters:
date -
Returns:
formatted string version of the specified date

getCurrentDate

Date getCurrentDate()
Returns the current date/time as a java.util.Date

Returns:
current date/time

getCurrentTimestamp

Timestamp getCurrentTimestamp()
Returns the current date/time as a java.sql.Timestamp

Returns:
current date/time

getCurrentSqlDate

Date getCurrentSqlDate()
Returns the current date/time as a java.sql.Date

Returns:
current date/time

getCurrentSqlDateMidnight

Date getCurrentSqlDateMidnight()
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.

Returns:
current date at the most recent midnight in the JVM's timezone

getCurrentCalendar

Calendar getCurrentCalendar()
Returns a Calendar initialized with the current Date

Returns:
currennt Calendar

getCalendar

Calendar getCalendar(Date date)
Returns a Calendar initialized to the given Date

Returns:
date-specific Calendar
Throws:
IllegalArgumentException - if the given Date is null

convertToDate

Date convertToDate(String dateString)
                   throws ParseException
Translates the specified string into a date without a time component, see implementation class for formatting details

Parameters:
dateString -
Returns:
the date representation of the specified dateString
Throws:
ParseException

convertToDateTime

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

Parameters:
dateTimeString -
Returns:
the date representation of the specified dateTimeString
Throws:
ParseException

convertToSqlTimestamp

Timestamp convertToSqlTimestamp(String timeString)
                                throws ParseException
Converts the given String into a java.sql.Timestamp instance according to the "stringDateTimeFormat" that the service is configured with

Parameters:
timeString -
Returns:
java.sql.Timestamp
Throws:
IllegalArgumentException - if the given string is null or blank
ParseException - if the string cannot be converted

convertToSqlDate

Date convertToSqlDate(String dateString)
                      throws ParseException
Converts the given String into a java.sql.Date instance

Parameters:
dateString -
Returns:
java.sql.Date
Throws:
IllegalArgumentException - if the given string is null or blank
ParseException - if the string cannot be converted

convertToSqlDate

Date convertToSqlDate(Timestamp timestamp)
                      throws ParseException
Converts a Timestamp into a sql Date.

Parameters:
timestamp -
Returns:
Throws:
ParseException

dateDiff

int dateDiff(Date date1,
             Date date2,
             boolean inclusive)
Returns the number of days between two days - start and end date of some arbitrary period.

Parameters:
date1 - The first date in the period
date2 - 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

toDateStringForFilename

String toDateStringForFilename(Date date)
Returns a String representing a date that is suitable for file names, and is preferably chronologically sortable

Parameters:
date -
Returns:

toDateTimeStringForFilename

String toDateTimeStringForFilename(Date date)
Returns a String representing a date/time that is suitable for file names, and is preferably chronologically sortable

Parameters:
date -
Returns:


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