Java Reference
In-Depth Information
Primitive Type
Wrapper Class
Minimum
Maximum
-128
127
byte
Byte
-32768
32767
short
Short
-2 31
2 31 - 1
int
Integer
-2 63
2 63 - 1
long
Long
2 −149
(2-2 −23 )×2 127
float
Float
2 −1074
(2-2 −52 )×2 1023
double
Double
Figure 5.2: Min and max values for number types
done at the last accepted decimal position. The input must also respect
the minimum and maximum values from Figure 5.2 .
Working with Dates
The date type converter attempts to parse the input to obtain a Date ,
with help from Java's DateFormat and a series of locale-sensitive format
patterns.
Just like the number type converters, the date type converter does some
preprocessing operations before trying to parse the input:
1. Replace all dashes ( - ), slashes ( / ), periods ( . ), and commas ( , ) with
spaces.
2. Collapse any sequences of two or more spaces to a single space.
3. If the result at this point is a string that contains two parts sepa-
rated by a space, assume that these are the day and month (or the
month and day). Since the year is required for any of the format
patterns to succeed, append a space and the current year to at
least give the input a chance of being parsed successfully.
By accepting any of - / . , as a separator but preprocessing the input
to replace the separators with spaces, the converter knows that at this
point the input is a date with the fields separated by a single space. It
becomes easy to match different date format patterns that also use a
space character as a separator, while allowing other separators in the
input.
Now that the date type converter is ready to parse the input, it tries
these date formats in order, using the first one that works.
 
 
 
Search WWH ::




Custom Search