From: Yasuhiro H. <Yas...@ma...> - 2012-09-25 12:41:55
|
Hi again, I used setLenient(FALSE) for a while, but I realized that our usage does not allow to use setLenient(FALSE). Our feature supports "rollover" behavior, which is that field value rolls into the next field if the field value is too high. For example, if hour value is "25" and day in month value is "07", we expect that those strings are parsed as "01" as hour value and "08" as day in month value. SimpleDateFormat::parse() supports this rollover behavior with lenient mode, and that is why we cannot use setLenient(FALSE). In addition, I noticed there are some other different behaviors. One of them causes a quite serious backward incompatible issue. I list those different behaviors between 4.4.2 and 49.1.2. 1) H, HH, h, and hh with lenient mode (setLenient(TRUE)) 49.1.2 cannot parse hour value if the hour value is greater than 24 even with lenient mode. This behavior does not seem consistent with others, such as minute or second. So, I am wondering if this is the expected behavior. Here is the difference. 49.1.2 : 0 through 24 can be parsed. 4.4.2 : 0 through 591 can be parsed. 2) M and MM with both lenient and non-lenient Full month name and three letters of month name can be parsed with "M" or "MM". This happens with bot lenient and non-lenient modes. Here is the difference. 49.1.2 (lenient) : greater than 0, full month name, and three letters of month name can be parsed. 4.4.2 (lenient) : greater than 0 can be parsed. 49.1.2 (non-lenient) : 1 through 12, full month name, and three letters of month name can be parsed. 4.4.2 (non-lenient) : 1 through 12 can be parsed. 3) MMM and MMMM with lenient mode (setLenient(TRUE)) Month in one or two digits can be parsed with "MMM" or "MMMM". Here is the difference. 49.1.2 : greater than 0, full month name, and three letters of month name can be parsed. 4.4.2 : full month name, and three letters of month name can be parsed. I am wondering if there are any workarounds, especially for 1). Best regards, /yasu |