Java study notes nine - date

  1. int getActualMaximum(Calender.DATE);
    // Returns the field value of the field used for the most

     

  2. Day_of_Year;
    // Today is the first day of the year

     

  3. int get(int field);
    // Returns the value of the specified calendar field field of

     

  4. Date getTime();
    // Get a Date object in the object calender

     

  5. void set(int field,int value);
    // the value of the specified field will be set to the value specified
    // Example:
    cal.set(Calender.YEAR,2008);
    // set the year 2008
    void set(int year,int month,int Date);

     

  6. abstract void add(int field,int mount);
    // the specified field, increase or decrease the amount of time specified

     

  7. void roll(int field,int amount);
    // This is the same function and add methods, allowed to exceed the maximum value, but without any carry, but standing around

     

  8. // java.text.DateFormat is the date / time format abstract class, we can complete the conversion between text and date

     

  9. Formatted date into the date string, parses the date, the date string is converted to

  10. Since the object is to create abstract class, can not directly create objects, but to create a subclass objects java.text.SimpleDateFormat;

  11. // constructor subclass
     SimpleDateFormat (String pattern);
    // using the specified format string pattern creation date format object

     

  12. // example
    DateFormat df=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

     

  13. Formatting rules:

    1. y Year

    2. M May

    3. d day

    4. When H

    5. m min

    6. s seconds

  14. Date parse(String source)
        // convert string objects time DATE

     

  15. // ParseException the Exception, when the source string analysis conditions is not satisfied, the custom date format is not satisfied; and this exception is a compile-time, check exception

Guess you like

Origin www.cnblogs.com/sunTyphonn/p/11768347.html