String to Date object in Android

35 Views Asked by At

I have two string values in one key for the date

Case 1 : date can be a string value ="2010-10-15T09:27:37Z"

Case 2 : and sometimes it can be a "20130526160000"

but I have only one function to parse these two value into date object

how can i identify that current value for date is case 1 or case 2 so that i can parse and will not get error

1

There are 1 best solutions below

0
xingbin On

If there are only these two cases, you can check whether the string contains literal T or Z.