0

How do I convert an ISO Date string to a Date object in Android 2.3?

I'm using the code below:

new Date('2013-08-25T06:30:00.000')

It's working on both iOS and other Android versions except for Android 2.3. When I execute the command above in Android 2.3, I am receiving an Invalid Date error message. It also important for me to keep the time part.

Thanks!

Arci
  • 6,647
  • 20
  • 70
  • 98

1 Answers1

0

Date class in java has following constructor and you can use one of them to create a Date object.

Date() 

Allocates a Date object and initializes it so that it represents the time at which it was allocated, measured to the nearest millisecond.

Date(int year, int month, int date)

Deprecated. As of JDK version 1.1, replaced by Calendar.set(year + 1900, month, date) or GregorianCalendar(year + 1900, month, date).

Date(int year, int month, int date, int hrs, int min)

Deprecated. As of JDK version 1.1, replaced by Calendar.set(year + 1900, month, date, hrs, min) or GregorianCalendar(year + 1900, month, date, hrs, min).

Date(int year, int month, int date, int hrs, int min, int sec)

Deprecated. As of JDK version 1.1, replaced by Calendar.set(year + 1900, month, date, hrs, min, sec) or GregorianCalendar(year + 1900, month, date, hrs, min, sec).

Date(long date) 

Allocates a Date object and initializes it to represent the specified number of milliseconds since the standard base time known as "the epoch", namely January 1, 1970, 00:00:00 GMT.

Date(String s)

Deprecated. As of JDK version 1.1, replaced by DateFormat.parse(String s).

for details look here

Mukesh Kumar Singh
  • 4,512
  • 2
  • 22
  • 30