1
My conversion from timestamp to Calendar was done, apparently successfully, as the data presented appeared correct except the day of the week.
data=(java.util.Gregoriancalendar) java.util.Gregoriancalendar[time=-125784706799416,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="America/Sao_Paulo",offset=-10800000,dstSavings=3600000,useDaylight=true,transitions=129,lastRule=java.util.SimpleTimeZone[id=America/Sao_Paulo,offset=-10800000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=9,startDay=15,startDayOfWeek=1,startTime=0,startTimeMode=0,endMode=3,endMonth=1,endDay=15,endDayOfWeek=1,endTime=0,endTimeMode=0]],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=0,YEAR=2017,MONTH=1,WEEK_OF_YEAR=6,WEEK_OF_MONTH=1,DAY_OF_MONTH=2,DAY_OF_YEAR=33,DAY_OF_WEEK=2,DAY_OF_WEEK_IN_MONTH=1,AM_PM=0,HOUR=8,HOUR_OF_DAY=8,MINUTE=40,SECOND=0,MILLISECOND=584,ZONE_OFFSET=-10800000,DST_OFFSET=0]
Note the following values:
YEAR: 2017 (OK)
MONTH: 1 (OK - Starts at 0, so we’re talking about February)
DAY_OF_YEAR: 33 (OK - since we have the 2nd of February)
DAY_OF_WEEK: 2 (WRONG, should be 5)
The following lines have been executed:
Calendar data = Calendar.getInstance();
data.set(0, 0, 0, 0, 0, 0);
data.setTime(arrAAM.get(i).getRegistroAulaAvulsa().getDataInicio());
NOTE: Remember that I tried in with milliseconds (setTimeInMillis
).
Tip - Use the
java.time.LocalDateTime
. Work withjava.util.Calendar
is horrible. See more here: http://answall.com/q/177129/132– Victor Stafusa
Thanks for the tip, but I am using Calendar throughout the system, and this caused me to be surprised, because apparently it is the only attribute that is incorrect.
– Lucas_Kunze
Dude, try to make it easier for people to help you by not putting the picture of the mistake, but the written mistake. And then try to define the Legends Timezone.
– viana