Pregunta

I was just wondering if there was quick way to convert a Time object represented as a String (through it's toString() method)

20130916T210230GMT(1,258,0,0,1379365350)

back into a Time object or some other easy object to extract individual details from such as time / day / month / year ect.

Is there a quick and dirty method or do we have to use something like SimpleDateFormat?

Edit

For clairty, I am refering to the Android time object.

¿Fue útil?

Solución

You can use Calendar or a library like Joda (I would recommend Joda). Just an example (you need to use formatter based on your requirements)

DateTimeFormatter formatter = DateTimeFormat.forPattern("dd/MM/yyyy HH:mm:ss");
DateTime dt = formatter.parseDateTime(string);
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top