Java Reference
In-Depth Information
is as forgiving as it can be, whereas strict parsing requires the format
and information to be proper and complete. The default is to be lenient.
You can use setLenient to set leniency to be true or false . You can test
leniency via isLenient .
The parsing methods are
public Date parse(String text) throws ParseException
Tries to parse text into a date and/or time. If successful, a
Date object is returned; otherwise, a ParseException is thrown.
public abstract Date parse(String text, ParsePosition pos)
Tries to parse text into a date and/or time. If successful, a
Date object is returned; otherwise, returns a null reference.
When the method is called, pos is the position at which to start
parsing; at the end it will either be positioned after the parsed
text or will remain unchanged if an error occurred.
public Object parseObject(String text, ParsePosition pos)
Returns the result of parse(text,pos) . This method is provided
to fulfill the generic contract of Format .
The class java.text.SimpleDateFormat is a concrete implementation of
DateFormat that is used in many locales. If you are writing a DateFormat
class, you may find it useful to extend SimpleDateFormat . SimpleDateFormat
uses methods in the DateFormatSymbols class to get localized strings and
symbols for date representation. When formatting or parsing dates, you
should usually not create SimpleDateFormat objects; instead, you should
use one of the "get instance" methods to return an appropriate format-
ter.
DateFormat has protected fields calendar and numberFormat that give direct
access to the values publicly manipulated with the set and get methods.
 
Search WWH ::




Custom Search