vendredi 24 avril 2015

java.lang.IllegalArgumentException: Parse error - Unable to parse Date in Android

I am storing the current date in SQLite db using the variable CURRENT_DATE. I found the date format used is yyyy-mm-dd in the same. I want to process the date in the code but I get this error:

java.lang.IllegalArgumentException: Parse error: at java.util.Date.parseError

The code is shown below:

    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-mm-dd");
    String formattedTaskDate = dateFormat.format(new Date(dateStoredAsStringFetchedFromDB));
    Date d = new Date(formattedTaskDate);

First I am fetching the date from the database and storing it in a String variable (because date is stored as TEXT in SQLite) and then I am performing the above operations but I get the exception as parseError.

How do I solve this issue?

Aucun commentaire:

Enregistrer un commentaire