1

error(java.text.ParseException: Unparseable date: "Nov 2 2017 09:44:00:000AM")

This is my code i use this on fragment

String tanggal = dataObject.getString("tgl_periksa");
DateFormat readFormat = new SimpleDateFormat("MM dd yyyy HH:mm:ss:SSSa");

DateFormat writeFormat = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss");
Date date = null;
try {
     date = readFormat.parse( tanggal );
} catch ( ParseException e ) {
  e.printStackTrace();
}
String formattedDate = "";
if( date != null ) {
   formattedDate = writeFormat.format( date );
}
dasa asas
  • 21
  • 4
  • I think I understand the question, but the title confuses me. Why and how do you want what divided into sections? – Ole V.V. Jul 24 '18 at 09:50
  • As an aside consider throwing away the long outmoded and notoriously troublesome `SimpleDateFormat` and friends, and adding [ThreeTenABP](https://github.com/JakeWharton/ThreeTenABP) to your Android project in order to use `java.time`, the modern Java date and time API. It is so much nicer to work with. – Ole V.V. Jul 24 '18 at 10:03

1 Answers1

1

change your readFormat pattern to it:

DateFormat readFormat = new SimpleDateFormat("MMM dd yyyy HH:mm:ss:SSSa")
GolamMazid Sajib
  • 8,698
  • 6
  • 21
  • 39