SimpleDateFormat——格式化时间类

格式化
  Date —— String
解析
  String ——Date
构造方法:
  SimpleDateFormat():使用默认的模式进行对象的构造
  SimpleDateFormat(String pattern):使用指定的模式进行的对象构建

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date();
String s = sdf.format(date);

Date d = sdf.parse("2019-12-12 11:34:23");

其他方法待学习后总结。。。。。

posted on 2019-11-07 10:01  大景少  阅读(191)  评论(0编辑  收藏  举报