ios - Date formatter returning null in some cases (after 12:59:59) -


i receiving json response this.

{         0 = 50;         1 = 1;         2 = 4;         3 = "08:51:00";         4 = "20:51:00";         id = 50;         day = 4;         endtime = "20:51:00";         opentime = "08:51:00";         venid = 1; 

and using date formatters convert string date , appropriate string format using code.

nsdateformatter * dateformat = [[nsdateformatter alloc] init]; [dateformat setdateformat:@"hh:mm:ss"];  nsdateformatter * recevingdateformatter = [[nsdateformatter alloc] init]; [recevingdateformatter setdateformat:@"hh:mm aa"];  nsdate * opentime = [dateformat datefromstring:[[_arrhoursofopr objectatindex:indexpath.row] objectforkey:@"opentime"]]; nsdate * endtime = [dateformat datefromstring:[[_arrhoursofopr objectatindex:indexpath.row] objectforkey:@"endtime"]]; nslog(@"the start time , end time %@, %@", opentime, endtime); objcell.txtday.text =  [_arr_weekdays objectatindex:[[[_arrhoursofopr objectatindex:indexpath.row]objectforkey:@"day"] integervalue]]; objcell.txtstarttime.text = [recevingdateformatter stringfromdate:opentime]; objcell.txtendtime.text =[recevingdateformatter stringfromdate:endtime]; 

but somehow "opentime" getting converted , "endtime" returning null.

this happening strings above 12:59:59 i.e starting time 13:00:00.

how can fix issue , support times later 12:59:59?

hh indicates hours in range of [1-12].

hour [1-12]. when used in skeleton data or in skeleton passed in api flexible date pattern generation, should match 12-hour-cycle format preferred locale (h or k); should not match 24-hour-cycle format (h or k). use hh 0 padding.

in particular "it should not match 24-hour-cycle format" important you, because want explicitly match 24-hour clock.

you need use hh support 13+ hours:

hour [0-23]. when used in skeleton data or in skeleton passed in api flexible date pattern generation, should match 24-hour-cycle format preferred locale (h or k); should not match 12-hour-cycle format (h or k). use hh 0 padding.

see unicode docs


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -