DateFormat
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Jon_Branham
Posted On:   Friday, June 20, 2003 09:46 PM

I am trying to set up a strict entry pattern for a date format of MM/dd/yyyy I used the following code: public static final SimpleDateFormat GLOBAL_DATE_FORMAT = new SimpleDateFormat("MM/dd/yyyy"); static{ NumberFormat nf = NumberFormat.getIntegerInstance(); nf.setMinimumIntegerDigits(2); nf.setMaximumIntegerDigits(4); GLOBAL_DATE_FORMAT.setNumberFormat(nf); GLOBAL_DATE_FORMAT.setLenient(false); } I call GLOBAL_DATE_FORMAT.parse(value) and it catches most things but lets an entry such as 1/20/2003 pass. Shouldn't the minimumIntegerDigits(2) force the "1" to be a "01"??    More>>

I am trying to set up a strict entry pattern for a date format of MM/dd/yyyy


I used the following code:

public static final SimpleDateFormat GLOBAL_DATE_FORMAT = new SimpleDateFormat("MM/dd/yyyy");

static{

NumberFormat nf = NumberFormat.getIntegerInstance();

nf.setMinimumIntegerDigits(2);

nf.setMaximumIntegerDigits(4);

GLOBAL_DATE_FORMAT.setNumberFormat(nf);

GLOBAL_DATE_FORMAT.setLenient(false);

}





I call GLOBAL_DATE_FORMAT.parse(value) and it catches most things but lets an entry such as 1/20/2003 pass. Shouldn't the minimumIntegerDigits(2) force the "1" to be a "01"??

   <<Less
About | Sitemap | Contact