java.text
Class SimpleDateFormat
- Cloneable, Serializable
SimpleDateFormat provides convenient methods for parsing and formatting
dates using Gregorian calendars (see java.util.GregorianCalendar).
AM_PM_FIELD , DATE_FIELD , DAY_OF_WEEK_FIELD , DAY_OF_WEEK_IN_MONTH_FIELD , DAY_OF_YEAR_FIELD , DEFAULT , ERA_FIELD , EXTENDED_YEAR_FIELD , FULL , HOUR0_FIELD , HOUR1_FIELD , HOUR_OF_DAY0_FIELD , HOUR_OF_DAY1_FIELD , ISO_YEAR_FIELD , LOCALIZED_DAY_OF_WEEK_FIELD , LONG , MEDIUM , MILLISECOND_FIELD , MILLISECOND_IN_DAY_FIELD , MINUTE_FIELD , MODIFIED_JULIAN_DAY_FIELD , MONTH_FIELD , RFC822_TIMEZONE_FIELD , SECOND_FIELD , SHORT , TIMEZONE_FIELD , WEEK_OF_MONTH_FIELD , WEEK_OF_YEAR_FIELD , YEAR_FIELD , calendar , numberFormat |
SimpleDateFormat() - Constructs a SimpleDateFormat using the default pattern for
the default locale.
|
SimpleDateFormat(String pattern) - Creates a date formatter using the specified non-localized pattern,
with the default DateFormatSymbols for the default locale.
|
SimpleDateFormat(String pattern, DateFormatSymbols formatData) - Creates a date formatter using the specified non-localized
pattern.
|
SimpleDateFormat(String pattern, Locale locale) - Creates a date formatter using the specified non-localized pattern,
with the default DateFormatSymbols for the given locale.
|
clone , equals , format , format , format , getAvailableLocales , getCalendar , getDateInstance , getDateInstance , getDateInstance , getDateTimeInstance , getDateTimeInstance , getDateTimeInstance , getInstance , getNumberFormat , getTimeInstance , getTimeInstance , getTimeInstance , getTimeZone , hashCode , isLenient , parse , parse , parseObject , setCalendar , setLenient , setNumberFormat , setTimeZone |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
SimpleDateFormat
public SimpleDateFormat()
Constructs a SimpleDateFormat using the default pattern for
the default locale.
SimpleDateFormat
public SimpleDateFormat(String pattern)
Creates a date formatter using the specified non-localized pattern,
with the default DateFormatSymbols for the default locale.
pattern
- the pattern to use.
SimpleDateFormat
public SimpleDateFormat(String pattern,
DateFormatSymbols formatData)
Creates a date formatter using the specified non-localized
pattern. The specified DateFormatSymbols will be used when
formatting.
pattern
- the non-localized pattern to use.formatData
- the formatting symbols to use.
SimpleDateFormat
public SimpleDateFormat(String pattern,
Locale locale)
Creates a date formatter using the specified non-localized pattern,
with the default DateFormatSymbols for the given locale.
pattern
- the non-localized pattern to use.locale
- the locale to use for the formatting symbols.
applyLocalizedPattern
public void applyLocalizedPattern(String pattern)
This method sets the formatting pattern that should be used by this
object. This string is localized.
pattern
- The new format pattern.
applyPattern
public void applyPattern(String pattern)
This method sets the formatting pattern that should be used by this
object. This string is not localized.
pattern
- The new format pattern.
clone
public Object clone()
Returns a copy of this instance of
SimpleDateFormat
. The copy contains
clones of the formatting symbols and the 2-digit
year century start date.
- clone in interface DateFormat
equals
public boolean equals(Object o)
This methods tests whether the specified object is equal to this
object. This will be true if and only if the specified object:
- Is not
null
. - Is an instance of
SimpleDateFormat
. - Is equal to this object at the superclass (i.e.,
DateFormat
)
level. - Has the same formatting pattern.
- Is using the same formatting symbols.
- Is using the same century for two digit years.
- equals in interface DateFormat
o
- The object to compare for equality against.
true
if the specified object is equal to this object,
false
otherwise.
get2DigitYearStart
public Date get2DigitYearStart()
Returns the start of the century used for two digit years.
- A
Date
representing the start of the century
for two digit years.
getDateFormatSymbols
public DateFormatSymbols getDateFormatSymbols()
This method returns a copy of the format symbol information used
for parsing and formatting dates.
- a copy of the date format symbols.
hashCode
public int hashCode()
This method returns a hash value for this object.
- hashCode in interface DateFormat
- A hash value for this object.
parse
public Date parse(String dateStr,
ParsePosition pos)
This method parses the specified string into a date.
- parse in interface DateFormat
dateStr
- The date string to parse.pos
- The input and output parse position
- The parsed date, or
null
if the string cannot be
parsed.
set2DigitYearStart
public void set2DigitYearStart(Date date)
Sets the start of the century used for two digit years.
date
- A Date
representing the start of the century for
two digit years.
setDateFormatSymbols
public void setDateFormatSymbols(DateFormatSymbols formatData)
This method sets the format symbols information used for parsing
and formatting dates.
formatData
- The date format symbols.
toLocalizedPattern
public String toLocalizedPattern()
This method returns a string with the formatting pattern being used
by this object. This string is localized.
toPattern
public String toPattern()
This method returns a string with the formatting pattern being used
by this object. This string is unlocalized.
toString
public String toString()
Returns a string representation of this
class.
- toString in interface Object
- a string representation of the
SimpleDateFormat
instance.
SimpleDateFormat.java -- A class for parsing/formating simple
date constructs
Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004, 2005
Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.