class DateTimeFormatter Formatter for printing and parsing date-time objects. Show
This class provides the main application entry point for printing and parsing and provides common implementations of
More complex formatters are provided by The main date-time classes provide two methods - one for
formatting, For example: LocalDate date = LocalDate.now(); String text = date.format(formatter); LocalDate parsedDate = LocalDate.parse(text, formatter); In addition to the format, formatters can be created with desired Locale, Chronology, ZoneId, and DecimalStyle. The The The The Some applications may need to use the older Predefined FormattersPredefined Formatters
Patterns for Formatting and Parsing Patterns are based on a simple sequence of letters and symbols. A pattern is used to create a Formatter using the For example: LocalDate date = LocalDate.now(); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy MM dd"); String text = date.format(formatter); LocalDate parsedDate = LocalDate.parse(text, formatter); All letters 'A' to 'Z' and 'a' to 'z' are reserved as pattern letters. The following pattern letters are defined: Pattern Letters and Symbols
The count of pattern letters determines the format. Text: The text style is determined based on the number of pattern letters used. Less than 4 pattern letters will use the Number: If the count of letters is one, then the value is output using the minimum number of digits and without padding. Otherwise, the count of digits is used as the width of the output field, with the value zero-padded as necessary. The following pattern letters have constraints on the count of letters. Only one letter of 'c' and 'F' can be specified. Up to two letters of 'd', 'H', 'h', 'K', 'k', 'm', and 's' can be specified. Up to three letters of 'D' can be specified. Number/Text: If the count of pattern letters is 3 or greater, use the Text rules above. Otherwise use the Number rules above. Fraction: Outputs the nano-of-second field as a fraction-of-second. The nano-of-second value has nine digits, thus the count of pattern letters is from 1 to 9. If it is less than 9, then the nano-of-second value is truncated, with only the most significant digits being output. Year: The count of letters determines the minimum field width below which padding is used. If the
count of letters is two, then a java.time.format.DateTimeFormatterBuilder#appendValueReduced two digit form is used. For printing, this outputs the rightmost two digits. For parsing, this will parse using the base value of 2000, resulting in a year within the range 2000 to 2099 inclusive. If the count of letters is less than four (but not two), then the sign is only output for negative years as per
ZoneId: This outputs the time-zone ID, such as 'Europe/Paris'. If the count of letters is two, then the time-zone ID is output. Any other count of letters throws Zone names: This outputs the display name of the time-zone ID. If the pattern letter is 'z' the output is the daylight savings aware zone name. If there is insufficient information to determine whether DST applies, the name ignoring daylight savings time will be used. If the count of
letters is one, two or three, then the short name is output. If the count of letters is four, then the full name is output. Five or more letters throws If the pattern letter is 'v' the output provides the zone name ignoring daylight savings time. If the count of letters is one, then the short name is output. If the count of letters is four, then the full name is output. Two, three and five or more letters throw Offset X and x: This formats the
offset based on the number of pattern letters. One letter outputs just the hour, such as '+01', unless the minute is non-zero in which case the minute is also output, such as '+0130'. Two letters outputs the hour and minute, without a colon, such as '+0130'. Three letters outputs the hour and minute, with a colon, such as '+01:30'. Four letters outputs the hour and minute and optional second, without a colon, such as '+013015'. Five letters outputs the hour and minute and optional second, with a
colon, such as '+01:30:15'. Six or more letters throws Offset O: This formats the localized offset based on the number of pattern letters. One letter outputs the short form of the
localized offset, which is localized offset text, such as 'GMT', with hour without leading zero, optional 2-digit minute and second if non-zero, and colon, for example 'GMT+8'. Four letters outputs the full form, which is localized offset text, such as 'GMT, with 2-digit hour and minute field, optional second field if non-zero, and colon, for example 'GMT+08:00'. Any other count of letters
throws Offset Z: This formats the offset based on the number of pattern letters. One, two or three letters outputs the hour and minute, without a colon, such as '+0130'. The output will be '+0000' when the offset is zero. Four letters outputs the full form of localized offset, equivalent to four letters of Offset-O. The output will be the corresponding
localized offset text if the offset is zero. Five letters outputs the hour, minute, with optional second if non-zero, with colon. It outputs 'Z' if the offset is zero. Six or more letters throws Optional section: The optional section markers work exactly like calling Pad modifier: Modifies the pattern that immediately follows to be padded with spaces. The pad width is determined by the number of pattern letters.
This is the same as calling For example, 'ppH' outputs the hour-of-day padded on the left with spaces to a width of 2. Any unrecognized letter is an error. Any non-letter character, other than '[', ']', '{', '}', '#' and the single quote will be output directly. Despite this, it is recommended to use single quotes around all characters that you want to output directly to ensure that future changes do not break your application. Resolving Parsing is implemented as a two-phase operation. First, the text is parsed using the layout defined by the formatter, producing a Five parsing methods are supplied by this class. Four of these perform both the parse and resolve phases. The fifth method, The resolve phase is controlled by two parameters, set on this class. The The Resolving separate fields to form a complete date and time is a complex process with behaviour distributed across a number of classes. It follows these steps:
Summary
Public methodsformatfun format(temporal: TemporalAccessor!): String! Formats a date-time object using this formatter. This formats the date-time to a String using the rules of the formatter.
formatTofun formatTo( Formats a date-time object to an This outputs the formatted date-time to the specified destination. Although
getChronologyfun getChronology(): Chronology! Gets the overriding chronology to be used during formatting. This returns the override chronology, used to convert dates. By default, a formatter has no override chronology, returning null. See
getDecimalStylefun getDecimalStyle(): DecimalStyle! Gets the DecimalStyle to be used during formatting.
getLocalefun getLocale(): Locale! Gets the locale to be used during formatting. This is used to lookup any part of the formatter needing specific localization, such as the text or localized pattern.
getResolverFieldsfun getResolverFields(): MutableSet<TemporalField!>! Gets the resolver fields to use during parsing. This returns the resolver fields, used during the second phase of parsing when fields are resolved into dates and times. By default, a formatter has no resolver fields, and thus returns null. See
getResolverStylefun getResolverStyle(): ResolverStyle! Gets the resolver style to use during parsing. This returns the resolver style, used during the second phase of parsing when fields are resolved into dates and times. By default, a formatter has the
getZonefun getZone(): ZoneId! Gets the overriding zone to be used during formatting. This returns the override zone, used to convert instants. By default, a formatter has no override zone, returning null. See
ofLocalizedDatestatic fun ofLocalizedDate(dateStyle: FormatStyle!): DateTimeFormatter! Returns a locale specific date format for the ISO chronology. This returns a formatter that will format or parse a date. The exact format pattern used varies by locale. The locale is determined from the formatter. The formatter returned directly by this method will use the Note that the localized pattern is looked up lazily. This The returned formatter has a chronology of ISO set to ensure dates in other calendar systems are correctly converted. It has no override zone and uses the
ofLocalizedDateTimestatic fun ofLocalizedDateTime(dateTimeStyle: FormatStyle!): DateTimeFormatter! Returns a locale specific date-time formatter for the ISO chronology. This returns a formatter that will format or parse a date-time. The exact format pattern used varies by locale. The locale is determined from the formatter. The formatter returned directly by this method will use the Note that the localized pattern is looked up lazily. This The returned formatter has a chronology of ISO set to ensure dates in other calendar systems are correctly converted. It has no override zone and uses the
ofLocalizedDateTimestatic fun ofLocalizedDateTime( Returns a locale specific date and time format for the ISO chronology. This returns a formatter that will format or parse a date-time. The exact format pattern used varies by locale. The locale is determined from the formatter. The formatter returned directly by this method will use the Note that the localized pattern is looked up lazily. This The returned formatter has a chronology of ISO set to ensure dates in other calendar systems are correctly converted. It has no override zone and uses the
ofLocalizedTimestatic fun ofLocalizedTime(timeStyle: FormatStyle!): DateTimeFormatter! Returns a locale specific time format for the ISO chronology. This returns a formatter that will format or parse a time. The exact format pattern used varies by locale. The locale is determined from the formatter. The formatter returned directly by this method will use the Note that the localized pattern is looked up lazily. This The returned formatter has a chronology of ISO set to ensure dates in other calendar systems are correctly converted. It has no override zone and uses the
ofPatternstatic fun ofPattern( Creates a formatter using the specified pattern and locale. This method will create a formatter based on a simple pattern of letters and symbols as described in the class documentation. For example, The formatter will use the specified locale. This can be changed using The returned formatter has no override chronology or zone. It uses
parsefun parse(text: CharSequence!): TemporalAccessor! Fully parses the text producing a temporal object. This parses the entire text producing a temporal object. It is typically more useful to use If the parse completes without reading the entire length of the text, or a problem occurs during parsing or merging, then an exception is thrown.
parsefun parse( Parses the text using this formatter, providing control over the text position. This parses the text without requiring the parse to start from the beginning of the string or finish at the end. The result of this method is The text will be parsed from the specified
start The operation of this method is slightly different to similar methods using If the formatter parses the same field more than once with different values, the result will be an error.
parsefun <T : Any!> parse( Fully parses the text producing an object of the specified type. Most applications should use this method for parsing. It parses the entire text to produce the required date-time. The query is typically a method reference to a LocalDateTime dt = parser.parse(str, LocalDateTime::from); If the parse completes without reading the entire length of the text, or a problem occurs during parsing or merging, then an exception is thrown.
parseBestfun parseBest( Fully parses the text producing an object of one of the specified types. This parse method is convenient for use when the parser can handle optional elements. For example, a pattern of 'uuuu-MM-dd HH.mm[ VV]' can be fully parsed to a The result is associated with the first type that successfully parses. Normally, applications will use TemporalAccessor dt = parser.parseBest(str, ZonedDateTime::from, LocalDateTime::from); if (dt instanceof ZonedDateTime) { ... } else { ... } If the parse completes without reading the entire length of the text, or a problem occurs during parsing or merging, then an exception is thrown.
parseUnresolvedfun parseUnresolved( Parses the text using this formatter, without resolving the result, intended for advanced use cases. Parsing is implemented as a two-phase operation. First, the text is parsed using the layout defined by the formatter, producing a The result of this method is The text will be parsed from the specified start Errors are returned using the error index field of the If the formatter parses the same field more than once with different values, the result will be an error. This method is intended for advanced use cases that need
access to the internal state during parsing. Typical application code should use
parsedExcessDaysstatic fun parsedExcessDays(): TemporalQuery<Period!>! A query that provides access to the excess days that were parsed. This returns a singleton query that provides access to additional information from the parse. The query always returns a non-null period, with a zero period returned instead of null. There are two situations where this query may return a non-zero period.
In both cases, if a complete The Text to parse Parsed object Excess days "2012-12-03T00:00" LocalDateTime.of(2012, 12, 3, 0, 0) ZERO "2012-12-03T24:00" LocalDateTime.of(2012, 12, 4, 0, 0) ZERO "00:00" LocalTime.of(0, 0) ZERO "24:00" LocalTime.of(0, 0) Period.ofDays(1) The query can be used as follows: TemporalAccessor parsed = formatter.parse(str); LocalTime time = parsed.query(LocalTime::from); Period extraDays = parsed.query(DateTimeFormatter.parsedExcessDays());
parsedLeapSecondstatic fun parsedLeapSecond(): TemporalQuery<Boolean!>! A query that provides access to whether a leap-second was parsed. This returns a singleton query that provides access to additional information from the parse. The query always returns a non-null boolean, true if parsing saw a leap-second, false if not. Instant parsing handles the special "leap second" time of '23:59:60'. Leap seconds occur at '23:59:60' in the UTC time-zone, but at other local times in different time-zones. To avoid this potential ambiguity, the handling of leap-seconds is limited to If the time '23:59:60' is received, then a simple conversion is applied, replacing the second-of-minute of 60 with 59. This
query can be used on the parse result to determine if the leap-second adjustment was made. The query will return TemporalAccessor parsed = formatter.parse(str); Instant instant = parsed.query(Instant::from); if (parsed.query(DateTimeFormatter.parsedLeapSecond())) { // validate leap-second is correct and apply correct smoothing }
toFormatfun toFormat(): Format! Returns this formatter as a The returned Exceptions will follow the definitions of
toFormatfun toFormat(parseQuery: TemporalQuery<*>!): Format! Returns this formatter as a The returned Exceptions will follow the definitions of
toStringfun toString(): String Returns a description of the underlying formatters.
withChronologyfun withChronology(chrono: Chronology!): DateTimeFormatter! Returns a copy of this formatter with a new override chronology. This returns a formatter with similar state to this formatter but with the override chronology set. By default, a formatter has no override chronology, returning null. If an override is added, then any date that is formatted or parsed will be affected. When formatting,
if the temporal object contains a date, then it will be converted to a date in the override chronology. Whether the temporal contains a date is determined by querying the If the temporal object does not contain a date, but does contain one or more When parsing, there are two distinct cases to consider. If a chronology has been parsed directly from the text, perhaps because This instance is immutable and unaffected by this method call.
withDecimalStylefun withDecimalStyle(decimalStyle: DecimalStyle!): DateTimeFormatter! Returns a copy of this formatter with a new DecimalStyle. This instance is immutable and unaffected by this method call.
withLocalefun withLocale(locale: Locale!): DateTimeFormatter! Returns a copy of this formatter with a new locale. This is used to lookup any part of the formatter needing specific localization, such as the text or localized pattern. The locale is stored as passed in, without further processing. This instance is immutable and unaffected by this method call.
withResolverFieldsfun withResolverFields(vararg resolverFields: TemporalField!): DateTimeFormatter! Returns a copy of this formatter with a new set of resolver fields. This returns a formatter with similar state to this formatter but with the resolver fields set. By default, a formatter has no resolver fields. Changing the resolver fields only has an effect during parsing. Parsing a text string occurs in two phases. Phase 1 is a basic text parse according to the fields added to the builder. Phase 2 resolves the parsed field-value pairs into date and/or time objects. The resolver fields are used to filter the field-value pairs between phase 1 and 2. This can be used to select between two or more ways that a date or time might be resolved. For example, if the formatter consists of year, month, day-of-month and day-of-year, then there are two ways to resolve a date. Calling this method with the arguments In a similar manner, this method can be used to ignore secondary fields that would otherwise be cross-checked. For example, if the formatter consists of year, month, day-of-month and day-of-week, then there is only one way to resolve a date, but the parsed value for day-of-week will be cross-checked against the
resolved date. Calling this method with the arguments In implementation terms, this method behaves as follows. The result of the parsing phase can be considered to be a map of field to value. The behavior of this method is to cause that map to be filtered between phase 1 and 2, removing all fields other than those specified as arguments to this method. This instance is immutable and unaffected by this method call.
withResolverFieldsfun withResolverFields(resolverFields: MutableSet<TemporalField!>!): DateTimeFormatter! Returns a copy of this formatter with a new set of resolver fields. This returns a formatter with similar state to this formatter but with the resolver fields set. By default, a formatter has no resolver fields. Changing the resolver fields only has an effect during parsing. Parsing a text string occurs in two phases. Phase 1 is a basic text parse according to the fields added to the builder. Phase 2 resolves the parsed field-value pairs into date and/or time objects. The resolver fields are used to filter the field-value pairs between phase 1 and 2. This can be used to select between two or more ways that a date or time might be resolved. For example, if the formatter consists of year, month, day-of-month and day-of-year, then there are two ways to resolve a date. Calling this method with the arguments
In a similar manner, this method can be used to ignore secondary fields that would otherwise be cross-checked. For example, if the formatter consists of year,
month, day-of-month and day-of-week, then there is only one way to resolve a date, but the parsed value for day-of-week will be cross-checked against the resolved date. Calling this method with the arguments In implementation terms, this method behaves as follows. The result of the parsing phase can be considered to be a map of field to value. The behavior of this method is to cause that map to be filtered between phase 1 and 2, removing all fields other than those specified as arguments to this method. This instance is immutable and unaffected by this method call.
withResolverStylefun withResolverStyle(resolverStyle: ResolverStyle!): DateTimeFormatter! Returns a copy of this formatter with a new resolver style. This returns a formatter with similar state to this formatter but with the resolver style set. By default, a formatter has the Changing the resolver style only has an effect during parsing. Parsing a text string occurs in two phases. Phase 1 is a
basic text parse according to the fields added to the builder. Phase 2 resolves the parsed field-value pairs into date and/or time objects. The resolver style is used to control how phase 2, resolving, happens. See This instance is immutable and unaffected by this method call.
withZonefun withZone(zone: ZoneId!): DateTimeFormatter! Returns a copy of this formatter with a new override zone. This returns a formatter with similar state to this formatter but with the override zone set. By default, a formatter has no override zone, returning null. If an override is added, then any instant that is formatted or parsed will be affected. When formatting, if the temporal object contains
an instant, then it will be converted to a zoned date-time using the override zone. Whether the temporal is an instant is determined by querying the If the temporal object does not contain an instant, but does contain an offset then an additional check is made. If the normalized override zone is an
offset that differs from the offset of the temporal, then a When parsing, there are two distinct cases to consider. If a zone has been parsed directly from the text, perhaps because This instance is immutable and unaffected by this method call.
PropertiesBASIC_ISO_DATEstatic val BASIC_ISO_DATE: DateTimeFormatter! The ISO date formatter that formats or parses a date without an offset, such as '20111203'. This returns an immutable formatter capable of formatting and parsing the ISO-8601 basic local date format. The format consists of:
As this formatter has an optional element, it may be necessary to parse using The returned formatter has a chronology of ISO set to ensure dates in other calendar systems are correctly converted. It has no override zone and uses the ISO_DATEstatic val ISO_DATE: DateTimeFormatter! The ISO date formatter that formats or parses a date with the offset if available, such as '2011-12-03' or '2011-12-03+01:00'. This returns an immutable formatter capable of formatting and parsing the ISO-8601 extended date format. The format consists of:
As this formatter has an
optional element, it may be necessary to parse using The returned formatter has a chronology of ISO set to ensure dates in other calendar systems are correctly converted. It has no override zone and uses the ISO_DATE_TIMEstatic val ISO_DATE_TIME: DateTimeFormatter! The ISO-like date-time formatter that formats or parses a date-time with the offset and zone if available, such as '2011-12-03T10:15:30', '2011-12-03T10:15:30+01:00' or '2011-12-03T10:15:30+01:00[Europe/Paris]'. This returns an immutable formatter capable of formatting and parsing the ISO-8601 extended local or offset date-time format, as well as the extended non-ISO form specifying the time-zone. The format consists of:
As this formatter has an optional element, it may be necessary to parse using The returned formatter has a chronology of ISO set to ensure dates in
other calendar systems are correctly converted. It has no override zone and uses the ISO_INSTANTstatic val ISO_INSTANT: DateTimeFormatter! The ISO instant formatter that formats or parses an instant in UTC, such as '2011-12-03T10:15:30Z'. This returns an immutable formatter capable of formatting and parsing the ISO-8601 instant format. When formatting, the second-of-minute is always output. The nano-of-second outputs zero, three, six or nine digits as necessary. When parsing, time to at least the seconds field is required. Fractional seconds from zero to nine are parsed. The localized decimal style is not used. This is a special case formatter intended to allow a human readable form of an The format consists of:
The returned formatter has no override chronology or zone. It uses the ISO_LOCAL_DATEstatic val ISO_LOCAL_DATE: DateTimeFormatter! The ISO date formatter that formats or parses a date without an offset, such as '2011-12-03'. This returns an immutable formatter capable of formatting and parsing the ISO-8601 extended local date format. The format consists of:
The returned formatter has a chronology of ISO set to ensure dates in other calendar systems are correctly converted. It has no override zone and uses the ISO_LOCAL_DATE_TIMEstatic val ISO_LOCAL_DATE_TIME: DateTimeFormatter! The ISO date-time formatter that formats or parses a date-time without an offset, such as '2011-12-03T10:15:30'. This returns an immutable formatter capable of formatting and parsing the ISO-8601 extended offset date-time format. The format consists of:
The returned formatter has a chronology of ISO set to ensure dates in other calendar systems are correctly
converted. It has no override zone and uses the ISO_LOCAL_TIMEstatic val ISO_LOCAL_TIME: DateTimeFormatter! The ISO time formatter that formats or parses a time without an offset, such as '10:15' or '10:15:30'. This returns an immutable formatter capable of formatting and parsing the ISO-8601 extended local time format. The format consists of:
The returned formatter has no override chronology or zone. It uses the ISO_OFFSET_DATEstatic val ISO_OFFSET_DATE: DateTimeFormatter! The ISO date formatter that formats or parses a date with an offset, such as '2011-12-03+01:00'. This returns an immutable formatter capable of formatting and parsing the ISO-8601 extended offset date format. The format consists of:
The returned formatter has a chronology of ISO set to ensure dates in other calendar systems are correctly converted. It has no override zone and uses the ISO_OFFSET_DATE_TIMEstatic val ISO_OFFSET_DATE_TIME: DateTimeFormatter! The ISO date-time formatter that formats or parses a date-time with an offset, such as '2011-12-03T10:15:30+01:00'. This returns an immutable formatter capable of formatting and parsing the ISO-8601 extended offset date-time format. The format consists of:
The returned formatter has a chronology of ISO set to ensure dates in other calendar systems are correctly converted. It has no override zone and uses the ISO_OFFSET_TIMEstatic val ISO_OFFSET_TIME: DateTimeFormatter! The ISO time formatter that formats or parses a time with an offset, such as '10:15+01:00' or '10:15:30+01:00'. This returns an immutable formatter capable of formatting and parsing the ISO-8601 extended offset time format. The format consists of:
The returned formatter has no override chronology or zone. It uses the ISO_ORDINAL_DATEstatic val ISO_ORDINAL_DATE: DateTimeFormatter! The ISO date formatter that formats or parses the ordinal date without an offset, such as '2012-337'. This returns an immutable formatter capable of formatting and parsing the ISO-8601 extended ordinal date format. The format consists of:
As this formatter has an optional element, it may be necessary to parse using The returned formatter has a chronology of ISO set to ensure dates
in other calendar systems are correctly converted. It has no override zone and uses the ISO_TIMEstatic val ISO_TIME: DateTimeFormatter! The ISO time formatter that formats or parses a time, with the offset if available, such as '10:15', '10:15:30' or '10:15:30+01:00'. This returns an immutable formatter capable of formatting and parsing the ISO-8601 extended offset time format. The format consists of:
As this formatter has an optional element, it may be necessary to parse using The returned formatter has no override chronology or zone. It uses the ISO_WEEK_DATEstatic val ISO_WEEK_DATE: DateTimeFormatter! The ISO date formatter that formats or parses the week-based date without an offset, such as '2012-W48-6'. This returns an immutable formatter capable of formatting and parsing the ISO-8601 extended week-based date format. The format consists of:
As this formatter has an optional element, it may be necessary to parse using The returned formatter has a chronology of ISO set to ensure dates in other calendar systems are correctly converted. It has no override zone and uses the ISO_ZONED_DATE_TIMEstatic val ISO_ZONED_DATE_TIME: DateTimeFormatter! The ISO-like date-time formatter that formats or parses a date-time with offset and zone, such as '2011-12-03T10:15:30+01:00[Europe/Paris]'. This returns an immutable formatter capable of formatting and parsing a format that extends the ISO-8601 extended offset date-time format to add the time-zone. The section in square brackets is not part of the ISO-8601 standard. The format consists of:
The returned formatter has a chronology of ISO set to ensure dates in other calendar systems are correctly converted. It has no override zone and uses the RFC_1123_DATE_TIMEstatic val RFC_1123_DATE_TIME: DateTimeFormatter! The RFC-1123 date-time formatter, such as 'Tue, 3 Jun 2008 11:05:30 GMT'. This returns an immutable formatter capable of formatting and parsing most of the RFC-1123 format. RFC-1123 updates RFC-822 changing the year from two digits to four. This implementation requires a four digit year. This implementation also does not handle North American or military zone names, only 'GMT' and offset amounts. The format consists of:
Parsing is case insensitive. The returned formatter has a chronology of ISO set to ensure dates in other calendar
systems are correctly converted. It has no override zone and uses the What is the default setting for the required property?The Required property uses the following settings. The field requires a value. (Default) The field doesn't require a value. You can set this property for all table fields (except AutoNumber data type fields) by using the table's property sheet or Visual Basic.
Which of the following symbols is used as a placeholder in custom formats for numeric fields?The number sign (#) is a Placeholder for digits. If there are no values, Access displays a blank space. To display zeroes instead of blank spaces. For example: to display 1234 as 1234.00, use the number 0 as the placeholder like this ####.
What properties are available for a field depend on quizlet?The properties for a field depend on the field's data type. A field property describes a field's contents beyond the field's basic data type, such as the number of characters the field can store or the allowable values that you can enter in the field.
What data type should you assign to a field that stores postal codes?The right data type for a postal code is a string. In a SQL database, this would typically be VARCHAR() or CHAR() , of the appropriate length. A numeric data type is not appropriate even if the values look like a number. Here is one simple reason: you cannot perform arithmetic on them.
|