I have an Android application that shows the creation date of a ticket with info I get from the server.
The thing is that I can't parse the string I'm getting I get an exception when I try to parse it with a SimpleDateFormat
This is what I get from the server:
2017-07-04 23:59:51.486559-05
This is the format I use to parse it:
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSX", Locale.ENGLISH);
The exception I'm getting with this approach is:
java.lang.IllegalArgumentException: Unknown pattern character 'X'
at java.text.SimpleDateFormat.validatePatternCharacter(SimpleDateFormat.java:323)
at java.text.SimpleDateFormat.validatePattern(SimpleDateFormat.java:312)
at java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:365)
at com.unipagos.app.wallet.payment.receipts.datamodels.PaymentReceipt.dateFromString(PaymentReceipt.java:320)
I've been at it for several hours and I've also tried with
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSZ", Locale.ENGLISH);
to no avail, getting this exception:
java.text.ParseException: Unparseable date: "2016-05-30 20:41:19.934959+00" (at offset 23)
at java.text.DateFormat.parse(DateFormat.java:579)
at com.unipagos.app.wallet.payment.receipts.datamodels.PaymentReceipt.dateFromString(PaymentReceipt.java:326)
at com.unipagos.app.wallet.payment.receipts.datamodels.PaymentReceipt.loadReceiptJSONObject(PaymentReceipt.java:164)
at com.unipagos.app.history.HistoryListFragment.populateTransactionList(HistoryListFragment.java:371)
at com.unipagos.app.history.HistoryListFragment.access$3200(HistoryListFragment.java:83)
Am I missing something?