I know there is the same question here, but I have tried the answer provided and it returned an output that I don't understand. I am confused by the answer and I don't think the output is correct.
I need help, thank you :)
GregorianCalendar date1 = new GregorianCalendar( 2014, 05, 12 ); //05 is june as month start from 0 -11
while( date1.get( Calendar.DAY_OF_WEEK ) != Calendar.MONDAY )
date1.add( Calendar.DATE, 1 );
System.out.println(date1);
Here is the output:
java.util.GregorianCalendar[time=1405267200000,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="Asia/Singapore",offset=28800000,dstSavings=0,useDaylight=false,transitions=9,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2014,MONTH=6,WEEK_OF_YEAR=29,WEEK_OF_MONTH=3,DAY_OF_MONTH=14,DAY_OF_YEAR=195,DAY_OF_WEEK=2,DAY_OF_WEEK_IN_MONTH=2,AM_PM=0,HOUR=0,HOUR_OF_DAY=0,MINUTE=0,SECOND=0,MILLISECOND=0,ZONE_OFFSET=28800000,DST_OFFSET=0]
Where on the output should I extract to retrieve Monday's date?
See Question&Answers more detail:os