[英]how to change T Z Format 2022-12-08T06:07:34.780Z (yyyy-MM-dd'T'HH:mm:ss.SSSZ) come to server but Display DD/MM/YYYY
2022-12-08T06:07:34.780Z 2022-12-08T06:07:34.780Z
12-10-2022 only仅限 12-10-2022
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(); }
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();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.