标签:href tle date throw ack stat ret time() date()
package com.qhong; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static void main(String[] args) throws Exception { DateFormat df=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS"); System.out.println(df.format(new Date())); Calendar calendar=Calendar.getInstance(); Date dt=calendar.getTime(); System.out.println(df.format(dt)); System.out.println(calendar.getWeekYear()); System.out.println(calendar.getFirstDayOfWeek()); System.out.println(calendar.getWeeksInWeekYear()); System.out.println("===================="); System.out.println(calendar.get(Calendar.YEAR)); System.out.println(calendar.get(Calendar.MONTH)); System.out.println(calendar.get(Calendar.DAY_OF_MONTH)); System.out.println(calendar.get(Calendar.DAY_OF_WEEK)); System.out.println(calendar.get(Calendar.DAY_OF_WEEK_IN_MONTH)); System.out.println(calendar.get(Calendar.DAY_OF_YEAR)); System.out.println("===================="); System.out.println(calendar.get(Calendar.DATE)); System.out.println(calendar.get(Calendar.HOUR)); System.out.println(calendar.get(Calendar.HOUR_OF_DAY)); System.out.println(calendar.get(Calendar.MINUTE)); System.out.println(calendar.get(Calendar.SECOND)); System.out.println("===================="); System.out.println(calendar.get(Calendar.MILLISECOND)); Calendar NewCalendar=Calendar.getInstance(); NewCalendar.setTime(new Date()); System.out.println(df.format(NewCalendar.getTime())); NewCalendar.add(Calendar.YEAR,-1); System.out.println(df.format(NewCalendar.getTime())); NewCalendar.add(Calendar.MONTH,2); System.out.println(df.format(NewCalendar.getTime())); NewCalendar.add(Calendar.DATE,3); //后者大,显示 -1 System.out.println(df.format(NewCalendar.getTime())); System.out.println("时间比较:"+NewCalendar.compareTo(calendar)); //前者大,显示 1 NewCalendar.add(Calendar.YEAR,1); System.out.println("时间比较:"+NewCalendar.compareTo(calendar)); } }
2017-03-13 22:36:08:393 2017-03-13 22:36:08:394 2017 1 52 ==================== 2017 2 13 2 2 72 ==================== 13 10 22 36 8 ==================== 394 2017-03-13 22:36:08:394 2016-03-13 22:36:08:394 2016-05-13 22:36:08:394 2016-05-16 22:36:08:394 时间比较:-1 时间比较:1
http://blog.csdn.net/joyous/article/details/9630893
http://sunnyhl.iteye.com/blog/1205820
标签:href tle date throw ack stat ret time() date()
原文地址:http://www.cnblogs.com/hongdada/p/6545497.html