The confusion is due to the fact that a period is just a parser separator, not a numeric decimal separator. Replace the character with, say : and the difference will be clearer.
That is, in locales, where . - decimal separator, numerically 1.5 = 1.50 = 1.500 .
However, when we analyze the lines "1.5" , "1.50" , "1.500" using . as a token separator, we get (1, 5) , (1, 50) , (1, 500) . . there is no special mathematical value, and this may be, say, the only gap.
This simple snippet also demonstrates the point:
SimpleDateFormat parser = new SimpleDateFormat("Z s#S"); System.out.println(parser.parse("GMT 1#002").getTime()); // 1002 System.out.println(parser.parse("GMT 1#02").getTime()); // 1002 System.out.println(parser.parse("GMT 1#2").getTime()); // 1002 System.out.println(parser.parse("GMT 1#20").getTime()); // 1020 System.out.println(parser.parse("GMT 1#200").getTime()); // 1200
source share