Why not just create an array of GregorianCalendar instances, exactly like an array of Strings?
GregorianCalendar[] myCal = new GregorianCalendar[99];
myCal[0] = Calendar.getInstance();
// etc
To output a GregorianCalendar instance in any specific text format you can imagine, use SimpleDateFormat, eg like this:
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
Calendar c = Calendar.getInstance(); // today
System.out.println(sdf.format(c.getTime()));
or use the java.util.Formatter class if you like C's printf approach
JamesCherrill
Posting Genius
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
Yes.
Input and output formats vary with locale, console vs GUI, user preferences etc, but a date is a date is a date regardless. Store the date and you're safe. Let people input them and view them however they want.
JamesCherrill
Posting Genius
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
Check the example in my previous post - you missed a method call
JamesCherrill
Posting Genius
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
Yes, it really is just the same as any other array, so you can do stuff like:
GregorianCalendar[] myCal = new GregorianCalendar[99];
myCal[0] = new GregorianCalendar(1980,1,1);
...
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
System.out.println(sdf.format(myCal[0].getTime()));
Just experiment a bit with it. Everything you know about arrays of Strings applies to arrays of GregorianCalendar also.
JamesCherrill
Posting Genius
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073