String转时间

xiaoxiao2021-02-28  64

Date date = new Date(); SimpleDateFormat h = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss"); String time = h.format(date); 现在 的时间是string类型的,可以放到表中。读取时先将这个string字符串读出来转成日期的就行 String  time = 读取出来的字符串 String fmt = "yyyy-mm-dd hh:mm:ss"; SimpleDateFormat sdf = new SimpleDateFormat(fmt); Date date; try { date = sdf.parse(time); } catch (Exception e) { e.printStackTrace(); }
转载请注明原文地址: https://www.6miu.com/read-2632304.html

最新回复(0)