时间和日期-<Date和SimpleDateFormat>

第一步、定义一个Date

   

                //获取当前时间
		Date now=new Date();

 

第二步、定义一个SimpleDateFormat

 

                //规范时间格式
		SimpleDateFormat  date=new SimpleDateFormat("yyyy-MM-dd hh-  mm-ss");
		String time=date.format(now);
		System.out.println("规范后的日期:"+time);

 

y年  M年中的月份  m小时中的分钟数     w年中的周数   W月份中的周数      D年中的天数    d月中的天数    F月份的星期   E星期中的天数

posted @ 2016-08-12 10:01  奔跑丶小清新  阅读(141)  评论(0)    收藏  举报