The example of this article tells the method of Java's time, month, and day. Share it for everyone for your reference. The specific implementation method is as follows:
package com.date.demo; Import java.text.parsexception; Import Java.text.simpleDateFormat; Import java.util.Calendar; law System.out.println("---------------获取当前时间的年月日-----------------"); getMonthDay (); System.out.println ("-------------------------------------------------------------------------------------------------------------------- "); GetmonthDay2Set ();} / *** Get the custom time* / Private Static void GetMonthday2Set () {string datestr =" 2013-11-10 18:45:39 "; w simpleDateFormat ("Yyyy-MM-DD HH: MM: SS"); Calendar Cal = Calendar.getInstance (); Date dt = null; try {dt = sdf.parse (dateStr); Cal.Settime (dt);} Catch ( PARESEEXCEPTION E) {// TODO Auto-GENERATCH BLOCK E.PrintStacktrace ();} int Year = Cal.get (Calendar.year); int 1; int days = call. get (calendar.day_of_month); int hours = call.get (calendar.hour_of_day); int Minute = Cal.get (Calendar.minute); OND); System.out.println (" === year === " + year); System.out.println (" === Month === " + Month); System.out.println (" === day === " + Day); System.out.println ("===" === " + Hour); System.out.println (" ==== " + minute); System.out.println (" === second = second = second = second = second = second = second = second = second = second = second = second = second = second = == " + second);} / *** Get the current time of the current time* / private static void getmonthday () {calendar call = calendar.getInstance (); int Year = Cal.get (Calendar.year); T Month = Cal.get (Calendar.month) + 1; int days = Cal.Get (calendar.day_of_month); int hours = call.get (calendar.hour_of_day); int minute = call.get ( Calendar.minute); int Second = Cal.get (Calendar.Second); System.out.println ("=== year ===" + year); systerm.out.println ("=== month ===" + month); .out.println ("=== day ===" + Day); System.out.println ("===" when === " + Hour); System.out.println (" === points == points == = " + minute); System.out.println (" === second === " + sex);}}It is hoped that this article is helpful to everyone's Java program design.