Hi all Mendix Guru. I have entity which has 24 dates attributes. JanuaryStartDate, JanuaryEndDate, FebruaryStartDate,..... In a form I am getting integer number as year. For example 2012. In a Java I am using this contruction for setting those dates: Calendar cal = Calendar.getInstance(new Locale("en", "GB")); cal.set(Calendar.YEAR, SiteParameter1.getBankingOverviewYear()); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); //january cal.set(Calendar.MONTH, 0); cal.set(Calendar.DAY_OF_MONTH, 1); Date startDate = new Date(cal.getTimeInMillis()); cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH)); Date endDate = new Date(cal.getTimeInMillis()); SiteParameter1.setJanStartDate(startDate); SiteParameter1.setJanEndDate(endDate); I am just changing the Calendar.MONTH. Can somebody explain me why if I execute this java action have some dates correct and some not: This is my output: January : "2012-01-01 00:00:00" - "2012-01-31 00:00:00" CORRECT June : "2012-05-31 23:00:00" - "2012-06-29 23:00:00" INCORRECT Regards, Lukas
It is because of British summer time :(.
Pretty sure cal.setTimeZone(TimeZone.getTimeZone("UTC")); would work if you want these dates to be in UTC.