问题描述
这是我的输入日期:
String myDate = "2010-02-19";
我想从上面的 DATE 获得输出,如下所示:
Friday,19-Feb-2010
这是我尝试使用 DateTimeFormatter 和 SimpleDateFormat 的代码:
button.setonClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String myDate = "2010-02-19";
String strDateTimeFormatter,strSimpleDateFormat;
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("EEEE,dd-MMM-yyyy",Locale.US);
LocalDate localDate = LocalDate.parse(myDate,dateTimeFormatter);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("EEEE,dd-MMM-yyyy");
strSimpleDateFormat = simpleDateFormat.format(myDate);
strDateTimeFormatter = String.valueOf(localDate);
Log.d("TAG","DateTimeFormatter: "+strDateTimeFormatter);
Log.d("TAG","SimpleDateFormat: "+strSimpleDateFormat);
}
});
我从以下行得到 java.time.format.DateTimeParseException: Text '2010-02-19' Could not be parsed at index 0
:
LocalDate localDate = LocalDate.parse(myDate,dateTimeFormatter);
如何获得我想要的实际输出?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)