Java-Date class and set (top), java-date class set

Source: Internet
Author: User
Tags date now

Java-Date class and set (top), java-date class set

1.1java.util.Data
Each force of data is used to represent a time point. Because he has design defects, most of the operation time methods are declared obsolete, and it is not recommended to use
Maintain this long value in each of his strengths. This value indicates the milliseconds that have elapsed since, January 1, January 1, 1970 to the date when the instance was created.
Void setTime (long MS) is given a long value so that the current date object represents the date
1.2java.text.SimoleDateFormat can convert date and string into each other according to the specified date format.
Date now = new Date ();
SimpleDateFormat sdf = new SimpleDateFormat ("yy/MM/dd HH: mm: ss E ");
String days = sdf. format (now );

Parses the string to date according to the specified date format
String string = "10:27:05 ";
SimpleDateFormat sdf = new SimpleDateFormat ("yyyy/MM/dd HH: mm: ss ");
Date date = sdf. parse (string );

1.3java.util.Calendar
Calendar is a common implementation class for operation time. gergoriancalendar is the Gregorian calendar. calendar provides the static method getinstance to obtain the implementation class applicable to the region where the current system is located. In most regions, the return class is the Gregorian calendar implementation class.
Calendar provides the following methods:
Date gettime () This method returns a date object. The date represented by this object is the date represented by the current calender.
Void settime (date) uses the given date class to set the current calendar to represent the date
Int get (int field) gets the value of the specified time component in the current calendar ar. The parameter is the specified time component, which corresponds to the related constant value provided by the calendar ar.
Void set (int field, int value) sets the specified value for the specified time component
Void add (int field, int calue) adds the given value to the specified time component. If the given value is negative, the value is subtracted.

2.1java.util.Collection
The set is used to store a group of elements, similar to the array function. The Set provides a set of methods to facilitate element operations, so it is easier to use than arrays.
Collection is the top-level interface of all sets and defines all
Methods. There are two common subinterfaces:
Java. util. List: Repeated sets, sorted. Features use subscript to operate elements.

Java. util. Set: whether the element in the non-repeated Set is repeated depends on the comparison result of the element's own equals.

Boolean add (object obj) add a set
Boolean contains (E) determines whether the current set contains the given element and compares equals to true.
Boolean remove () deletes a set Element

 

I am a beginner. If any updates are poor, I would like to thank you!

More highlights will be updated later!

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.