我通过以下方式获取系统当前日期和时间:
String months[] = {"Jan", "Feb", "Mar", "Apr","May", "Jun", "Jul", "Aug","Sep", "Oct", "Nov", "Dec"};
Calendar cal = new GregorianCalendar();
String month = (months[cal.get(Calendar.MONTH)]);
int year = cal.get(Calendar.YEAR);
int day = cal.get(Calendar.DAY_OF_MONTH);
int second = cal.get(Calendar.SECOND);
int minute = cal.get(Calendar.MINUTE);
int hour = cal.get(Calendar.HOUR);
String date= day+"/"+month+"/"+year;
String time=hour+":"+minute+":"+second;
ps.setString(14, date+" "+time);
但是,现在当我尝试使用上述准备好的语句在表中插入日期和时间时。
出现以下错误:
日期格式图片在转换整个输入字符串之前结束
我该如何解决这个问题?