Class SimpleTimestampFormat
- java.lang.Object
-
- java.text.Format
-
- java.text.DateFormat
-
- java.text.SimpleDateFormat
-
- org.pentaho.di.core.row.value.timestamp.SimpleTimestampFormat
-
- All Implemented Interfaces:
Serializable
,Cloneable
public class SimpleTimestampFormat extends SimpleDateFormat
User: Dzmitry Stsiapanau Date: 3/13/14 Time: 6:32 PM- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.text.DateFormat
DateFormat.Field
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_TIMESTAMP_FORMAT
Default format of theTimestamp
object for sql.-
Fields inherited from class java.text.DateFormat
AM_PM_FIELD, calendar, DATE_FIELD, DAY_OF_WEEK_FIELD, DAY_OF_WEEK_IN_MONTH_FIELD, DAY_OF_YEAR_FIELD, DEFAULT, ERA_FIELD, FULL, HOUR_OF_DAY0_FIELD, HOUR_OF_DAY1_FIELD, HOUR0_FIELD, HOUR1_FIELD, LONG, MEDIUM, MILLISECOND_FIELD, MINUTE_FIELD, MONTH_FIELD, numberFormat, SECOND_FIELD, SHORT, TIMEZONE_FIELD, WEEK_OF_MONTH_FIELD, WEEK_OF_YEAR_FIELD, YEAR_FIELD
-
-
Constructor Summary
Constructors Constructor Description SimpleTimestampFormat(String pattern)
Constructs aSimpleTimestampFormat
using the given pattern and the default date format symbols for the default locale.SimpleTimestampFormat(String pattern, DateFormatSymbols formatSymbols)
Constructs ausing the given pattern and date format symbols. SimpleTimestampFormat(String pattern, Locale locale)
Constructs aSimpleTimestampFormat
using the given pattern and the default date format symbols for the given locale.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
applyLocalizedPattern(String pattern)
Applies the given localized pattern string to this date format.void
applyPattern(String pattern)
Applies the given pattern string to this date format.StringBuffer
format(Date timestamp, StringBuffer toAppendTo, FieldPosition pos)
Formats the givenDate
or>Timestamp
into a date/time string and appends the result to the givenStringBuffer
.AttributedCharacterIterator
formatToCharacterIterator(Object obj)
SeeSimpleDateFormat
description.Date
parse(String source)
Parses text from the beginning of the given string to produce a date.Date
parse(String text, ParsePosition pos)
Parses text from a string to produce aTimestamp
.Object
parseObject(String source, ParsePosition pos)
Parses text from a string to produce aDate
.void
setDateFormatSymbols(DateFormatSymbols newFormatSymbols)
Sets the date and time format symbols of this date format.String
toLocalizedPattern()
Returns a localized pattern string describing this date format.String
toPattern()
Returns a pattern string describing this date format.-
Methods inherited from class java.text.SimpleDateFormat
clone, equals, get2DigitYearStart, getDateFormatSymbols, hashCode, set2DigitYearStart
-
Methods inherited from class java.text.DateFormat
format, format, getAvailableLocales, getCalendar, getDateInstance, getDateInstance, getDateInstance, getDateTimeInstance, getDateTimeInstance, getDateTimeInstance, getInstance, getNumberFormat, getTimeInstance, getTimeInstance, getTimeInstance, getTimeZone, isLenient, setCalendar, setLenient, setNumberFormat, setTimeZone
-
Methods inherited from class java.text.Format
format, parseObject
-
-
-
-
Field Detail
-
DEFAULT_TIMESTAMP_FORMAT
public static final String DEFAULT_TIMESTAMP_FORMAT
Default format of theTimestamp
object for sql.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SimpleTimestampFormat
public SimpleTimestampFormat(String pattern)
Constructs aSimpleTimestampFormat
using the given pattern and the default date format symbols for the default locale. Note: This constructor may not support all locales. For full coverage, use the factory methods in theSimpleTimestampFormat
class.- Parameters:
pattern
- the pattern describing the date and time format- Throws:
NullPointerException
- if the given pattern is nullIllegalArgumentException
- if the given pattern is invalid
-
SimpleTimestampFormat
public SimpleTimestampFormat(String pattern, Locale locale)
Constructs aSimpleTimestampFormat
using the given pattern and the default date format symbols for the given locale. Note: This constructor may not support all locales. For full coverage, use the factory methods in theSimpleTimestampFormat
class.- Parameters:
pattern
- the pattern describing the date and time formatlocale
- the locale whose date format symbols should be used- Throws:
NullPointerException
- if the given pattern or locale is nullIllegalArgumentException
- if the given pattern is invalid
-
SimpleTimestampFormat
public SimpleTimestampFormat(String pattern, DateFormatSymbols formatSymbols)
Constructs ausing the given pattern and date format symbols. - Parameters:
pattern
- the pattern describing the date and time formatformatSymbols
- the date format symbols to be used for formatting- Throws:
NullPointerException
- if the given pattern or formatSymbols is nullIllegalArgumentException
- if the given pattern is invalid
-
-
Method Detail
-
setDateFormatSymbols
public void setDateFormatSymbols(DateFormatSymbols newFormatSymbols)
Sets the date and time format symbols of this date format.- Overrides:
setDateFormatSymbols
in classSimpleDateFormat
- Parameters:
newFormatSymbols
- the new date and time format symbols- Throws:
NullPointerException
- if the given newFormatSymbols is null- See Also:
SimpleDateFormat.getDateFormatSymbols()
-
format
public StringBuffer format(Date timestamp, StringBuffer toAppendTo, FieldPosition pos)
Formats the givenDate
or>Timestamp
into a date/time string and appends the result to the givenStringBuffer
.- Overrides:
format
in classSimpleDateFormat
- Parameters:
timestamp
- the date-time value to be formatted into a date-time string.toAppendTo
- where the new date-time text is to be appended.pos
- the formatting position. On input: an alignment field, if desired. On output: the offsets of the alignment field.- Returns:
- the formatted date-time string.
- Throws:
NullPointerException
- if the giventimestamp
isnull
.
-
formatToCharacterIterator
public AttributedCharacterIterator formatToCharacterIterator(Object obj)
SeeSimpleDateFormat
description. This is dummy method to deprecate using parent implementation forTimestamp
until it is not fully implemented.- Overrides:
formatToCharacterIterator
in classSimpleDateFormat
-
parse
public Date parse(String text, ParsePosition pos)
Parses text from a string to produce aTimestamp
. The method attempts to parse text starting at the index given bypos
. If parsing succeeds, then the index ofpos
is updated to the index after the last character used (parsing does not necessarily use all characters up to the end of the string), and the parsed date is returned. The updatedpos
can be used to indicate the starting point for the next call to this method. If an error occurs, then the index ofpos
is not changed, the error index ofpos
is set to the index of the character where the error occurred, and null is returned.This parsing operation uses the
calendar
to produce aDate
. All of thecalendar
's date-time fields are cleared before parsing, and thecalendar
's default values of the date-time fields are used for any missing date-time information. For example, the year value of the parsedDate
is 1970 withGregorianCalendar
if no year value is given from the parsing operation. TheTimeZone
value may be overwritten, depending on the given pattern and the time zone value intext
. AnyTimeZone
value that has previously been set by a call tosetTimeZone
may need to be restored for further operations.- Overrides:
parse
in classSimpleDateFormat
- Parameters:
text
- AString
, part of which should be parsed.pos
- AParsePosition
object with index and error index information as described above.- Returns:
- A
Date
parsed from the string. In case of error, returns null. - Throws:
NullPointerException
- iftext
orpos
is null.
-
toPattern
public String toPattern()
Returns a pattern string describing this date format.- Overrides:
toPattern
in classSimpleDateFormat
- Returns:
- a pattern string describing this date format.
-
toLocalizedPattern
public String toLocalizedPattern()
Returns a localized pattern string describing this date format.- Overrides:
toLocalizedPattern
in classSimpleDateFormat
- Returns:
- a localized pattern string describing this date format.
-
applyPattern
public void applyPattern(String pattern)
Applies the given pattern string to this date format.- Overrides:
applyPattern
in classSimpleDateFormat
- Parameters:
pattern
- the new date and time pattern for this date format- Throws:
NullPointerException
- if the given pattern is nullIllegalArgumentException
- if the given pattern is invalid
-
applyLocalizedPattern
public void applyLocalizedPattern(String pattern)
Applies the given localized pattern string to this date format.- Overrides:
applyLocalizedPattern
in classSimpleDateFormat
- Parameters:
pattern
- a String to be mapped to the new date and time format pattern for this format- Throws:
NullPointerException
- if the given pattern is nullIllegalArgumentException
- if the given pattern is invalid
-
parse
public Date parse(String source) throws ParseException
Parses text from the beginning of the given string to produce a date. The method may not use the entire text of the given string. See theparse(String, java.text.ParsePosition)
method for more information on date parsing.- Overrides:
parse
in classDateFormat
- Parameters:
source
- AString
whose beginning should be parsed.- Returns:
- A
Date
parsed from the string. - Throws:
ParseException
- if the beginning of the specified string cannot be parsed.
-
parseObject
public Object parseObject(String source, ParsePosition pos)
Parses text from a string to produce aDate
. The method attempts to parse text starting at the index given bypos
. If parsing succeeds, then the index ofpos
is updated to the index after the last character used (parsing does not necessarily use all characters up to the end of the string), and the parsed date is returned. The updatedpos
can be used to indicate the starting point for the next call to this method. If an error occurs, then the index ofpos
is not changed, the error index ofpos
is set to the index of the character where the error occurred, and null is returned. See theparse(String, java.text.ParsePosition)
method for more information on date parsing.- Overrides:
parseObject
in classDateFormat
- Parameters:
source
- AString
, part of which should be parsed.pos
- AParsePosition
object with index and error index information as described above.- Returns:
- A
Date
parsed from the string. In case of error, returns null. - Throws:
NullPointerException
- ifpos
is null.
-
-