TpoM6oH
TpoM6oH

Reputation: 8585

Can't understand date parsing

I have string "1/28/2013 3:26:51 PM"

SimpleDateFormat formatter = new SimpleDateFormat("M/dd/yyyy h:mm:ss a");
    try {
        this.createDate = formatter.parse(xmlPhoto.getCreateDate());
        this.shootDate = formatter.parse(xmlPhoto.getShootDate());
    } catch (ParseException e) {
        e.printStackTrace();
    }

I want to make a Date object from this String, but I get a ParseExceprion and offset = 19.

Upvotes: 0

Views: 85

Answers (1)

Reimeus
Reimeus

Reputation: 159774

The AM/PM marker may not be be matching with that from your default Locale. try with:

new SimpleDateFormat("M/dd/yyyy h:mm:ss a", Locale.ENGLISH)

Upvotes: 4

Related Questions