public class TimestampFormat extends Format
SimpleDateFormat
, except
that it supports the nanosecond field identified by N.
For example, the pattern "yyyy-MM-dd'T'HH:mm:ss.NNNNNNNNNZ" formats to 2001-07-04T12:08:56.012345678-0700
Parsing is not currently supported if nanosecond field is used.
Format.Field
Constructor and Description |
---|
TimestampFormat()
Creates a new TimestampFormat using the current Locale.
|
TimestampFormat(String pattern)
Creates a new TimestampFormat using the given pattern and the symbols
from the current Locale.
|
TimestampFormat(String pattern,
DateFormatSymbols symbols)
Creates a new TimestampFormat using the given pattern and symbols.
|
TimestampFormat(String pattern,
Locale locale)
Creates a new TimestampFormat using the given pattern and the symbols
from the current Locale.
|
Modifier and Type | Method and Description |
---|---|
StringBuffer |
format(Object obj,
StringBuffer toAppendTo,
FieldPosition pos) |
String |
format(Timestamp Timestamp)
Formats the given Timestamp.
|
TimeZone |
getTimeZone()
Returns the time zone used to format the Timestamp.
|
Timestamp |
parse(String source)
Parses a String and converts it to a Timestamp.
|
Timestamp |
parse(String source,
ParsePosition pos)
Parses the source at the given position.
|
Object |
parseObject(String source,
ParsePosition pos) |
void |
setTimeZome(TimeZone zone)
Changes the time zone used to format the Timestamp.
|
clone, format, formatToCharacterIterator, parseObject
public TimestampFormat()
public TimestampFormat(String pattern)
pattern
- the pattern describing the date and time formatpublic TimestampFormat(String pattern, DateFormatSymbols symbols)
pattern
- the pattern describing the date and time formatsymbols
- symbols to be used in formattingpublic void setTimeZome(TimeZone zone)
zone
- a new time zonepublic TimeZone getTimeZone()
public StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos)
public String format(Timestamp Timestamp)
Timestamp
- a Timestamppublic Timestamp parse(String source, ParsePosition pos)
source
- text to parsepos
- the positionpublic Object parseObject(String source, ParsePosition pos)
parseObject
in class Format
public Timestamp parse(String source) throws ParseException
source
- the string to parseParseException
- if the string does not match the patternCopyright © 2015. All rights reserved.