com.ivata.mask.web.format
Interface DateFormatter


public interface DateFormatter

This interface defines a formatter which is used to parse dates in a standard way, system-wide.

Note that ivata masks does not provide an implementation of this interface. For an example implementation, look at the class SettingDateFormatter in ivata groupware.

Since:
ivata masks 0.5 (2005-01-11)
Version:
$Revision: 1.2 $
Author:
Colin MacLeod colin.macleod@ivata.com

Method Summary
 java.lang.String format(java.util.Date date)
          Format the date provided as a string.
 int getDateFormat()
          Get the number of the date format used in this object.
 java.lang.String getDateTimeText()
          Get how the date and time are used in the output.
 int getTimeFormat()
          Get the number of the time format used in this object.
 java.util.Date parse(java.lang.String formatString)
          Parse the given string to a date, using the current date format.
 void setDateFormat(int dateFormat)
          Set the number of the date format used in this object.
 void setDateTimeText(java.lang.String dateTimeText)
          Set this text to restrict the output to just date or just time, or to change the text between them.
 void setTimeFormat(int timeFormat)
          Set the number of the time format used in this object.
 

Method Detail

format

public java.lang.String format(java.util.Date date)
                        throws DateFormatterException

Format the date provided as a string.

Parameters:
date - the date to convert into a string.
Returns:
date string, converted to a string, using the requested format.
Throws:
DateFormatterException - if there is a problem creating the string because of an incorrect format pattern, for example.

getDateFormat

public int getDateFormat()

Get the number of the date format used in this object. This should correspond to one of the DATE_FORMAT_... constants.

Returns:
the current value of the date format used.

getDateTimeText

public java.lang.String getDateTimeText()

Get how the date and time are used in the output.

The format used is the same as the format for java.text.MessageFormat and the string {0} will be replaced with the date format chosen, {1} is replaced with the time format chosen.

Returns:
the current text used to combine date and time formats.

getTimeFormat

public int getTimeFormat()

Get the number of the time format used in this object. This should correspond to one of the TIME_FORMAT_... constants.

Returns:
the current value of the time format used.

parse

public java.util.Date parse(java.lang.String formatString)
                     throws java.text.ParseException,
                            DateFormatterException

Parse the given string to a date, using the current date format.

Parameters:
formatString - the string to convert into a date.
Returns:
date parsed from the string provided.
Throws:
java.text.ParseException - if the string cannot be parsed into a date object.
DateFormatterException - if the settings for this date format are not set, or not set correctly

setDateFormat

public void setDateFormat(int dateFormat)
                   throws DateFormatterException

Set the number of the date format used in this object. This should correspond to one of the DATE_FORMAT_... constants.

Parameters:
dateFormat - the new value of the date format used.
Throws:
DateFormatterException - if the settings for this date format are not set, or not set correctly

setDateTimeText

public void setDateTimeText(java.lang.String dateTimeText)
                     throws DateFormatterException

Set this text to restrict the output to just date or just time, or to change the text between them.

The format used is the same as the format for java.text.MessageFormat and the string {0} will be replaced with the date format chosen, {1} is replaced with the time format chosen.

Parameters:
dateTimeText - the new value of the text used to combine date and time formats.
Throws:
DateFormatterException - if the settings for this date format are not set, or not set correctly

setTimeFormat

public void setTimeFormat(int timeFormat)
                   throws DateFormatterException

Set the number of the time format used in this object. This should correspond to one of the TIME_FORMAT_... constants.

Parameters:
timeFormat - the new value of the time format used.
Throws:
DateFormatterException - if the settings for this date format are not set, or not set correctly


Copyright © 2001-2005 ivata limited. All Rights Reserved.