Converting EDT time to Local Time in Objective C

72 views Asked by At

In my project , we have a requirement to convert the server sent time (EDT) to local time and display on UI . I have written the below code which seems to be working perfectly fine in simulator but ,it displays as blank on device .

Due to the security constraints , in my company USBV access is disabled ,so i cant debug this on device directly .PFB the code im using ..

NSDateFormatter *formatSelectedTime = [[NSDateFormatter alloc] init];

[formatSelectedTime  setDateFormat:@"EEE MMM dd HH:mm:ss zzz yyyy"];

    NSTimeZone *sourceTimezone =[NSTimeZone timeZoneWithAbbreviation:@"EDT"];
    NSTimeZone *destinationTimeZone = [NSTimeZone localTimeZone];
    formatSelectedTime.timeZone = sourceTimezone;
    NSDate *filledDateInEDT = [formatSelectedTime dateFromString:fillsDetails.tradeDetails.filledTimeStr];


    formatSelectedTime.timeZone = destinationTimeZone;
    NSString *filledTimeInLocalString  = [formatSelectedTime stringFromDate:filledDateInEDT];
1

There are 1 answers

0
Rango On

Not sure why my post is downvoted , but i figured out the problem . i was using a custom font for the label i have used to display the converted time and for some reason it showed properly on simulator but not on device.. i have re-added the font and everything worked fine..