黑马程序员技术交流社区

标题: 字符串与时间的转换 [打印本页]

作者: charryxiaocai    时间: 2015-9-28 23:19
标题: 字符串与时间的转换
String ---> Date  解析parse()
      String time = “2015-09-28 10:11:55”;   
                String geshi = “yyy-MM-dd HH:mm:ss”;
SimpleDateFormat sdf = new SimpleDateFormat(geshi);
                Date d2 = sdf.parse(time);
                System.out.println(d2);       
       
       
Date - -> String
                Date d = new Date();
                String geshi = “yyyy年MM月dd日 HH:mm:ss”;
                SimpleDateFormat sdf = new SimpleDateFormat(geshi);
                String time = sdf.format(d);
               





欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2