Interface IDateSymbol
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
AbstractFormatOnlySymbol
,CentiSecondSymbol
,DateSymbol
,DeciSecondSymbol
,HourSymbol
,LeadingZeroShortHourSymbol
,MeridiemMarkerSymbol
,MilliSecondSymbol
,MinuteSymbol
,MonthSymbol
,NumberSymbol
,SecondSymbol
,SeparatorSymbol
,ShortDateSymbol
,ShortHourSymbol
,ShortMonthSymbol
,ShortYearSymbol
,SpelledDayOfWeekSymbol
,SpelledDaySymbol
,SpelledMonthSymbol
,SpelledShortMonthSymbol
,SpelledYearSymbol
,YearSymbol
Interface for symbols used by the DateFormat class to format or parse a date object or string. It defines the methods common to all types of symbols.
Known implementations:
NumberSymbol, SeparatorSymbol
- Since:
- 5.1
- Author:
- C. de Meijer
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoid
format
(Calendar c, StringBuffer sb) Formats this symbol's field of the specified Calendar, and appends it to the StringBuffer.Return the pattern representation of this NumberSymbol.int
getWidth()
Returns the width of the symbol.int
Parses part of the dateString parameter.
-
Method Details
-
format
Formats this symbol's field of the specified Calendar, and appends it to the StringBuffer.- Parameters:
c
- Calendar object which holds the date/time that needs to be formatted. The instance is created inside the format method of the DateFormat class.sb
- StringBuffer in which to place the result of the formatting operation.
-
getWidth
int getWidth()Returns the width of the symbol. When parsing a date string without separators, this width is used to calculate the expected total string length. When parsing a date string with separators, this width is used to limit the maximum amount of characters to consider. The result of this method is used during formatting to determine the number of leading zeroes required.- Returns:
- int The width of this symbol.
-
parse
Parses part of the dateString parameter. This method may return a negative integer to indicate failure.- Parameters:
dateString
- String value containing the date/time representation to be parsed.pos
- Integer value indicating the position at which to start parsing.maxWidth
- Integer value indicating the maximum number of characters to consume.- Returns:
- Non-negative integer containing the value parsed.
- Negative integer indicating a parse error. (Will be handled by DateFormat by throwing a ParseException indicating the position of the error).
- Throws:
ParseException
- if for some reason the specified dateString parameter could not be parsed.
-
getPattern
String getPattern()Return the pattern representation of this NumberSymbol.- Returns:
- String representing the pattern.
-