将日期从 yyyy-mm-dd 转换为 utc 格式
Convert date from yyyy-mm-dd to utc format
我有一个日期,“2015-06-08”。我想将其转换为“2015 年 6 月 8 日”
String oldDateString = "2015-06-08";
SimpleDateFormat oldDateFormat = new SimpleDateFormat("yyyy-mm-dd", Locale.getDefault());
SimpleDateFormat newDateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.getDefault());
Date date = oldDateFormat.parse(oldDateString);
String result = newDateFormat.format(date);
但这不能正常工作。它 returns “2015 年 1 月 8 日”。我做错了什么?
使用 yyyy-MM-dd
代替 yyyy-mm-dd
因为 'm' 小写是分钟。
文档:link
我有一个日期,“2015-06-08”。我想将其转换为“2015 年 6 月 8 日”
String oldDateString = "2015-06-08";
SimpleDateFormat oldDateFormat = new SimpleDateFormat("yyyy-mm-dd", Locale.getDefault());
SimpleDateFormat newDateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.getDefault());
Date date = oldDateFormat.parse(oldDateString);
String result = newDateFormat.format(date);
但这不能正常工作。它 returns “2015 年 1 月 8 日”。我做错了什么?
使用 yyyy-MM-dd
代替 yyyy-mm-dd
因为 'm' 小写是分钟。
文档:link