java日历相关操作记录
1.对字符串的时间格式 yyyy-MM-dd HH:mm:ss 相关操作
public static void main(String[] args) throws ParseException { String time = "2015-10-08 17:56:59"; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); java.util.Date date_util = sdf.parse(time); //转换为util.date java.sql.Date date_sql = new java.sql.Date(date_util.getTime()+(long)(0.5*60*60*1000));//转换为sql.date System.out.println(date_util); System.out.println(date_sql); String date = sdf.format(date_sql); System.out.println(date); date = sdf.format(date_util); System.out.println(date); }
本文来自博客园踩坑狭,作者:韩若明瞳,转载请注明原文链接:https://www.cnblogs.com/han-guang-xue/p/11640558.html