转换dd-mmm-yyyy为dd-mm-yyyy格式。
String dateofbirth = ((JTextField) dobcalender.getDateEditor().getUiComponent()).getText();//date from jcalender
SimpleDateFormat myFormat = new SimpleDateFormat("dd-MM-yyyy");
Run Code Online (Sandbox Code Playgroud)
尝试了以下代码:
System.out.println(myFormat.format(myFormat.parse(dateofbirth)));
myFormat.format(myFormat.parse(dateofbirth));
Run Code Online (Sandbox Code Playgroud)
显示错误parseexception