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
Varun ChopraVarun Chopra 

Salesforce is setting date one day off to the original date while uploading csv file using apex.

I am trying to upload a csv file in salesforce through apex code. In salesforce after uploading the csv file , date field is showing one day off.

For e.g. I am uploading 16-08-2015 in date field but in salesforce it shows 15-08-2015.

I know it is due to timezone problem but i want to resolve it. Can anyone have any idea to resolve this??

Thanks in advance!!!!
Jayson Faderanga 14Jayson Faderanga 14
something like that bro :D
date_field__c = system.today.add(1)
Lakdar ARABILakdar ARABI
    Try this, it depends on the user time zone and it always works :

    public Datetime current = System.now(); // returns date time value in GMT time zone.     
    public TimeZone tz = UserInfo.getTimeZone();   // returns the user time zone.    
    public DateTime ddayDateTime = current.AddSeconds(tz.getOffset(current)/1000);