L
Lars Uffmann
Simple code snippet:
===================
Calendar date = Calendar.getInstance();
date.set(Calendar.YEAR, 2007);
date.set(Calendar.MONTH, 4);
date.set(Calendar.DAY_OF_MONTH, 30);
date.add(Calendar.DAY_OF_YEAR, 1);
===================
After this manipulation, the date reads out as 2007-04-31 - reading it
with date.get(Calendar.YEAR), date.get(Calendar.MONTH) and
date.get(Calendar.DAY_OF_MONTH).
Same behaviour when calling add with field Calendar.DAY_OF_MONTH.
This is with Compiler compliance 1.5 and 1.6 in Sun Java.
Is anyone able to tell me how I can tell this Calendar class to do
proper date calculation? I don't want to do everything by hand,
accounting for leap years - I just want to add a certain amount of days
to a date and get the date of the result...
Thanks for any hints!
Lars
===================
Calendar date = Calendar.getInstance();
date.set(Calendar.YEAR, 2007);
date.set(Calendar.MONTH, 4);
date.set(Calendar.DAY_OF_MONTH, 30);
date.add(Calendar.DAY_OF_YEAR, 1);
===================
After this manipulation, the date reads out as 2007-04-31 - reading it
with date.get(Calendar.YEAR), date.get(Calendar.MONTH) and
date.get(Calendar.DAY_OF_MONTH).
Same behaviour when calling add with field Calendar.DAY_OF_MONTH.
This is with Compiler compliance 1.5 and 1.6 in Sun Java.
Is anyone able to tell me how I can tell this Calendar class to do
proper date calculation? I don't want to do everything by hand,
accounting for leap years - I just want to add a certain amount of days
to a date and get the date of the result...
Thanks for any hints!
Lars