java在通过SimpleDateFormat获取时间存数据库时如果不格式化会出现【20-10-26 上午10:47】的时间样式,oracle在处理时就很烦
未经过格式化处理的时间:
String cttime = new SimpleDateFormat().format(new Date());
System.out.println(cttime);
运行结果:20-10-26 上午10:47
格式化处理过的时间:
Date date = new Date();
String strDateFormat = "yyyy-MM-dd HH:mm:ss";
SimpleDateFormat sdf = new SimpleDateFormat(strDateFormat);
System.out.println(sdf.format(date));
运行结果:2020-10-26 11:02:34
oracle在处理带上午字样的时间时:
select to_date('2020-10-26 星期一 上午10:25','yyyy-mm-dd DAY AM hh:mi:ss') from dual
运行结果:2020-10-26 10:25:00