小弟想把系统时间格式化成YYYY-MM-DD格式传送到SQL中
Calendar ca = new GregorianCalendar();
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
后边如何实现,最好能写代码,谢谢了
Calendar ca = new GregorianCalendar();
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
后边如何实现,最好能写代码,谢谢了
但是忘记怎么弄得了
资料目前也不再手上
好像不是很麻烦的问题啊
帮你定起来吧
if(date == null || format == null) {
return null;
} else {
SimpleDateFormat sdf = new SimpleDateFormat(format);
return sdf.format(date);
}
}
date 是时间,formate是格式