我正在尝试将日期格式从“dow mon dd hh:mm:ss zzz yyyy”转换为“MM / dd / yyyy”
String inputPattern = "dow mon dd hh:mm:ss zzz yyyy";
String outputPattern = "MM/dd/yyyy";
SimpleDateFormat inputFormat = new SimpleDateFormat(inputPattern);
SimpleDateFormat outputFormat = new SimpleDateFormat(outputPattern);
Date date=inputFormat.parse("Tue Dec 07 15:59:03 IST 2010");
System.out.println("Date : "+outputFormat.format(date));
但是在运行上面的代码时会出现以下异常
Exception in thread "main" java.lang.IllegalArgumentException: Illegal pattern character 'o'
at java.text.SimpleDateFormat.compile(SimpleDateFormat.java:769)
at java.text.SimpleDateFormat.initialize(SimpleDateFormat.java:576)
at java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:501)
at java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:476)
at com.kpub.web.bean.action.ReportGeneration.main(ReportGeneration.java:198)
可能是什么问题?