2022-12-08T06:07:34.780Z 12-10-2022 only please Help me
Utility.log_d("Date12343",orderlist.getCreatedAt()); /Calendar c = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat(orderlist.getCreatedAt(), Locale.ENGLISH); Log.e("TAG", "formatted string: " sdf.format(c.getTime()));/ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); sdf.setTimeZone(TimeZone.getTimeZone("GMT")); try { sdf.parse(orderlist.getCreatedAt()); } catch (ParseException e) { e.printStackTrace(); }
CodePudding user response:
you have to format using simple date format.
String initialStringDate = "2019-01-27T09:27:37Z";
Locale us = new Locale("US");
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", us);
try {
Date date = format.parse(initialStringDate);
String stringDate = new SimpleDateFormat("dd/MM/yyyy", us).format(date);
Log.i("Date", "" stringDate );
} catch (ParseException e) {
e.printStackTrace();
}