jd.util
Class DateFormat

java.lang.Object
  extended byjd.util.DateFormat

public class DateFormat
extends Object

DateFormat prvoides locale dependent formatting of dates.


Field Summary
static char SYMBOL_DAY
           
static char SYMBOL_MONTH
           
static char SYMBOL_YEAR
           
 
Method Summary
 String format(Date date)
          Return a string representation of a date.
 void format(Date date, StringBuffer s)
          Return a string representation of a date.
 void format(Date date, StringBuffer s, char ignorePart)
          Return a string representation of a date.
 String format(int year, int month, int day)
          Return a string representation of a date.
 void format(int year, int month, int day, StringBuffer s)
          Return a string representation of a date.
 void format(int year, int month, int day, StringBuffer s, char ignorePart)
          Return a string representation of a date.
 int getDayPosition()
          Return the position (0-2) of the day value in date string.
static DateFormat getDefaultFormat()
          Return a DateFormat for the default locale.
static DateFormat getFormat(Locale locale)
          Return a DateFormat for a locale.
static DateFormat getFormat(String language)
          Return a DateFormat for a language.
static DateFormat getFormat(String language, String country)
          Return a DateFormat for a language and country.
 String getMonthName(int month)
          Return the name of a month
 int getMonthPosition()
          Returns the position (0-2) of the month value in date string.
 char getSeparatorSymbol()
          Return the locale dependent symbol which separates date parts (e.g.
 String getShortMonthName(int month)
          Return the short name of a month
 String getShortWeekdayName(int weekday)
          Return the short name of a weekday
 String getWeekdayName(int weekday)
          Return the name of a weekday
 int getYearPosition()
          Returns the position (0-2) of the year value in date string.
 Date parse(String text)
          Parses a date from a string representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SYMBOL_MONTH

public static final char SYMBOL_MONTH
See Also:
Constant Field Values

SYMBOL_DAY

public static final char SYMBOL_DAY
See Also:
Constant Field Values

SYMBOL_YEAR

public static final char SYMBOL_YEAR
See Also:
Constant Field Values
Method Detail

getDefaultFormat

public static DateFormat getDefaultFormat()
Return a DateFormat for the default locale.


getFormat

public static DateFormat getFormat(String language)
Return a DateFormat for a language.

Parameters:
language - lowercase two-letter ISO-639 code.

getFormat

public static DateFormat getFormat(String language,
                                   String country)
Return a DateFormat for a language and country.

Parameters:
language - lowercase two-letter ISO-639 code.
country - uppercase two-letter ISO-3166 code.

getFormat

public static DateFormat getFormat(Locale locale)
Return a DateFormat for a locale.


getSeparatorSymbol

public char getSeparatorSymbol()
Return the locale dependent symbol which separates date parts (e.g. '.' or '/').


getDayPosition

public int getDayPosition()
Return the position (0-2) of the day value in date string.


getMonthPosition

public int getMonthPosition()
Returns the position (0-2) of the month value in date string.


getYearPosition

public int getYearPosition()
Returns the position (0-2) of the year value in date string.


getMonthName

public String getMonthName(int month)
Return the name of a month

Parameters:
month - the month (ranging from 1 to 12)

getShortMonthName

public String getShortMonthName(int month)
Return the short name of a month

Parameters:
month - the month (ranging from 1 to 12)

getWeekdayName

public String getWeekdayName(int weekday)
Return the name of a weekday

Parameters:
weekday - the weekday
See Also:
Date.WEEKDAY_SUNDAY

getShortWeekdayName

public String getShortWeekdayName(int weekday)
Return the short name of a weekday

Parameters:
weekday - the weekday
See Also:
Date.WEEKDAY_SUNDAY

parse

public Date parse(String text)
           throws ParseException
Parses a date from a string representation.

Throws:
ParseException - thrown if an parse error occurs

format

public String format(Date date)
Return a string representation of a date.


format

public void format(Date date,
                   StringBuffer s)
Return a string representation of a date.

Parameters:
date - the date
s - a StringBuffer to hold the result

format

public void format(Date date,
                   StringBuffer s,
                   char ignorePart)
Return a string representation of a date.

Parameters:
date - the date
s - a StringBuffer to hold the result
ignorePart - exclude a date part from the result string
See Also:
SYMBOL_MONTH, SYMBOL_DAY, SYMBOL_YEAR

format

public String format(int year,
                     int month,
                     int day)
Return a string representation of a date.

Parameters:
year - the year (the year 2001 is specified as 2001)
month - the month (counting from 1 to 12)
day - the day (counting from 1 to 31)

format

public void format(int year,
                   int month,
                   int day,
                   StringBuffer s)
Return a string representation of a date.

Parameters:
year - the year (the year 2001 is specified as 2001)
month - the month (counting from 1 to 12)
day - the day (counting from 1 to 31)
s - a StringBuffer to hold the result

format

public void format(int year,
                   int month,
                   int day,
                   StringBuffer s,
                   char ignorePart)
Return a string representation of a date.

Parameters:
year - the year (the year 2001 is specified as 2001)
month - the month (counting from 1 to 12)
day - the day (counting from 1 to 31)
s - a StringBuffer to hold the result
ignorePart - exclude a date part from the result string
See Also:
SYMBOL_MONTH, SYMBOL_DAY, SYMBOL_YEAR