function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
baseball123baseball123 

Timezone Issue

All, 

 

I tried to set a date to SFDC. The timestamp is Mon Jun 04 20:17:53 EDT 2012 but when the date get populated to SFDC, the date fields shows as 6/5/2012. I even printed the calendar info before populates it to SFDC and the calendar shows it's June 04. The data the code is getting is from Germany. I have tried different timezone such as "Europe/Zurich" and "GMT" and both of them don't work. Why does SFDC automatically add hours to this timestamp?

 

The code and system.out.print is below:

 

Date sDate = getStartDate(); 

Calendar startDate = new GregorianCalendar(TimeZone.getTimeZone("America/New_York"));
startDate.setTime(sDate);

 

startDate.getTime() is Mon Jun 04 20:17:53 EDT 2012
startDate is java.util.GregorianCalendar[time=1338855473000,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="America/New_York",offset=-18000000,dstSavings=3600000,useDaylight=true,transitions=235,lastRule=java.util.SimpleTimeZone[id=America/New_York,offset=-18000000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,endMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2012,MONTH=5,WEEK_OF_YEAR=23,WEEK_OF_MONTH=2,DAY_OF_MONTH=4,DAY_OF_YEAR=156,DAY_OF_WEEK=2,DAY_OF_WEEK_IN_MONTH=1,AM_PM=1,HOUR=8,HOUR_OF_DAY=20,MINUTE=17,SECOND=53,MILLISECOND=0,ZONE_OFFSET=-18000000,DST_OFFSET=3600000]
 

Thanks in advance,