我无法在将12小时日期时间格式转换为24小时日期时格式时解析日期。代码为
List_CallDateTime=rs.getString(5);
System.out.print(List_CallDateTime);
String str=List_CallDateTime;
SimpleDateFormat callreadFormat=new SimpleDateFormat("MM/dd/yyyy hh:mm aa",Locale.US);
SimpleDateFormat callwirteformat=new SimpleDateFormat("MMM dd yyyy HH:mm",Locale.US);
Date calldate=null;
calldate=callreadFormat.parse(str);
String callcreatedate=callwirteformat.format(calldate);
System.out.println("asdsad"+callcreatedate);
我得到的例外是
StandardWrapperValve[jsp]: PWC1406: Servlet.service() for servlet jsp threw exception
java.text.ParseException: Unparseable date: "04/25/2012 9:00AM"
答案 0 :(得分:1)
您可以使用
轻松设置smalldatetime
字段的格式
SimpleDateFormat writeFormat=new SimpleDateFormat("MMM dd yyyy HH:mm"
,Locale.US);
String strDate=writeFormat.format(rs.getTimestamp(5));