mysql date string类型_mysql date类型与string转换
/**
* 將string轉換為yyyyMMddHHmmss格式的Date型
* @param time
* @return java.util.Date
*/
public static Date convertStringToDate(String time) {
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss"); ??Date date = null; ??if (time != null ????&& !"".equals(time)) { ???try { ????date = format.parse(time); ???} catch (Exception e) { ????System.out.println(e.getMessage()); ???} ??} ??return date; ?} ? ?/** ? * 將Date型格式化yyyy-MM-dd HH:mm:ss String ? * @param date ? * @return String (yyyy-MM-dd HH:mm:ss) ? */ ?public static String convertDateToString(Date date){ ??SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); ??String strDate = format.format(date); ??return strDate; ?}
總結
以上是生活随笔為你收集整理的mysql date string类型_mysql date类型与string转换的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql不支持union_Mysql中
- 下一篇: spring连接mysql出现问题_使用