In fact, when learning this, the self-feeling learned what direct query API can be, there is no need to study how to use a method,
Focus on learning the methods that are often used. Feel their own blog, just like their own notes, with the time, you can quickly find
The resources that you need, learning more time is the way to, and then pay the effort.
Code:
1 Packagecom.day13.date;2 3 Importjava.text.ParseException;4 ImportJava.text.SimpleDateFormat;5 ImportJava.util.Calendar;6 Importjava.util.Date;7 8 /**9 * Class description:D ateTen * @authorAuthor: Chenyanlong One * @versionCreation Date: October 28, 2017 A */ - Public classDemo1 { - the Public Static voidMain (string[] args) { - - /* - Date Date=new date ();//Gets the current system time + System.out.println (Date.getyear ());//horizontal line indicates outdated meaning - + A Calendar calendar=calendar.getinstance ();//Time to get the system at System.out.println ("Year:" +calendar.get (Calendar.year));//year - System.out.println ("Month:" + (Calendar.get (calendar.month) +1));//Remember to add 1, otherwise the month of the month that will be output - System.out.println ("Day:" +calendar.get (Calendar.date));//day - - //(Time has 24 binary calendar.hour_of_day and 12 binary calendar.hour), minutes, seconds - System.out.println ("Time:" +calendar.get (Calendar.hour_of_day)); in System.out.println ("Points:" +calendar.get (Calendar.minute)); - System.out.println ("Seconds:" +calendar.get (Calendar.second));*/ to + /* - * Displays the current system time: December 26, 2014 the * Role 1: The date can be converted to the specified format of the string format () * * Role 2: Convert a string to the corresponding date parse () Birthday $ */Panax NotoginsengDate date=NewDate (); -SimpleDateFormat dateformat=NewSimpleDateFormat ("yyyy mm month DD Day HH:MM:SS"); theString Time=dateformat.format (date);//converts a date to a string in a specified format +SYSTEM.OUT.PRINTLN ("Current system time:" +Time ); A theString birthday= "December 26, 2000 11:00:00"; + Date Date2; - Try { $Date2 =dateformat.parse (birthday); $ System.out.println (date2); -}Catch(ParseException e) { - //TODO auto-generated Catch block the e.printstacktrace (); - }Wuyi the } - Wu}Operating effect:
Special attention:
Summary of Java Foundation Basics-----Date