2, other class API------Calendar

Source: Internet
Author: User

Gets the specified date information in the date such as get year, month, day

1  Packagecn.itcast.api.a.date;2 3 ImportJava.util.Calendar;4 5  Public classDateDemo2 {6 7     /**8      * @paramargs9      */Ten      Public Static voidMain (string[] args) { One          A         //Requirement 2: Based on requirement 1, gets the date and time of the string information (local).  -         //How do I get the date information specified in the string? For example to get years, and to judge.  -         //1, gets the date object. Date the //Date date = new Date (); -          -         //jdk1.1 begins the Calendar. //gets the Calendar object.  -Calendar C = calendar.getinstance ();// +          -         intYear =C.get (calendar.year); +         intmonth = C.get (calendar.month) +1; A         intDay =C.get (calendar.day_of_month); atString week =Getcnweek (C.get (Calendar.day_of_week)); -          -         //Information about the date and year of the printed information is here. Gets the value of the specified field Oh, yes.  -SYSTEM.OUT.PRINTLN (year+ "year" +month+ "month" +day+ "Day" +week); -          -     } in     //Let the week field correspond to the Chinese week. Tabular Array.  -  to      Public StaticString Getcnweek (inti) { +         if(i<0 | | i>7){ -             Throw NewRuntimeException (i+ "no corresponding Week"); the         } *         //define the table.  $String[] weeks = {"", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};Panax Notoginseng          -         returnWeeks[i]; the     } +      A      the      +      -      $      $  -}

2, other class API------Calendar

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.