Posted By:
Adam_Rabung
Posted On:
Saturday, October 26, 2002 09:04 AM
Hello, I am wondering if anyone has come up with a clever solution to a problem presented by Java's SHORT date format. When parsing user date input, we use DateFormat.getDateInstance(DateFormat.SHORT) to parse it. Unfortunately, this format specifies a 2-digit year (mm/dd/yy). It does, however, accept 4-digit years, but when it formats (as opposed to parse) a date it uses the 2-digit format. I'd like to, if possible, disallow 2-digit dates without losing the i18n benefits of DateFormat.getDateInstance(). setLenient does not help in this situation: it allows 2 or 4 digit years in strict or lenient mode. MEDIUM and LONG formats don't seem like good formats for users to type. I also understand it is not always safe to cast the return value of getDa
More>>
Hello,
I am wondering if anyone has come up with a clever solution to a problem presented by Java's SHORT date format. When parsing user date input, we use DateFormat.getDateInstance(DateFormat.SHORT) to parse it. Unfortunately, this format specifies a 2-digit year (mm/dd/yy). It does, however, accept 4-digit years, but when it formats (as opposed to parse) a date it uses the 2-digit format. I'd like to, if possible, disallow 2-digit dates without losing the i18n benefits of DateFormat.getDateInstance(). setLenient does not help in this situation: it allows 2 or 4 digit years in strict or lenient mode. MEDIUM and LONG formats don't seem like good formats for users to type. I also understand it is not always safe to cast the return value of getDateInstance into a SimpleDateFormat (which would allow me to perform some regular expression replacement on the default format, which feels completely breakable anyway). Has anyone solved this problem without breaking i18n?
Any input is much appreciated,
Adam
<<Less