Summary of Java Foundation Basics-----Date

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.