Javase Study Notes: The eighth chapter of common Class Util Toolkit date class, digital class

Source: Internet
Author: User
Tags time in milliseconds

The date class is located in Java. Util Tool Kit
Before (date when) tests whether this date is before the specified date.
GetDay () Get a day of the week
GetDate () Get a day of the month
The Calendar class is located in Java. Util Tool Kit
Calendar c1=calendar.getinstance (); Get a calendar using the default time zone and locale
int Year=c1.get (C1.  year); Gets the year of the current date
int Mon=c1.get (calendar.month); Get the month of the current date
int Day=c1.get (calendar.date); Gets the number of days of the current date
int Wday=c1.get (C1. Day_of_week);//Gets the number of weeks that the current date resides on
int Yday=c1.get (C1. Day_of_year);//Gets the number of days in the year of the current date
int Am=c1.get (C1.AM_PM);//Get the current time of the morning 0 or the afternoon
int Ms=c1.get (c1.millisecond);//Gets the current time in milliseconds
C1.gettime (); Get current time
C1.set (2015,12,11);//Set Month Day
/*
* Set November 19, 2012 11:12:12 250 and print
*/
Calendar c2=calendar.getinstance ();
C2.set (2012, 11, 19, 11, 12, 12);
C2.set (C2.millisecond, 250);
System.out.println (C2.get (C2. Year) + "Years" +c2.get (C2. Month) + "Monthly" +c2.get (C2. Date) + "day \ T" +c2.get (C2. HOUR) + ":" +c2.get (C2. MINUTE) + ":" +c2.get (C2. SECOND) + "\ T" +c2.get (C2.millisecond));

Third, the SimpleDateFormat class is located in the Java.text package, the date is formatted into a string, the string parsing date
Applypattern (string pattern) applies the given pattern string to this date format
Parse (string text, Parseposition POS) parses the text of a string, generating a Date.

SimpleDateFormat sdf=new SimpleDateFormat ();
Sdf.applypattern ("Yyyy-mm-dd"); Set Date format
String s= Sdf.format (D1); Print the date in the specified format
System.out.println (s);

Iv. the DecimalFormat class is located in the Java.text package for formatting decimal digits
DecimalFormat df=new DecimalFormat ();
Df.applypattern ("¥##,###.00");//digital format parameter setting
String s= Df.format (56766666666.00); To set the value
System.out.println (s);
V. Scanner category scan belongs to Java.util package
Hasnext () Determine if the scan has content
while (Sc.hasnext ()) {
String s =sc.next ();
}

Vi. Random Number
R.nextint ();

Job: 1, provides a DateTime tool class that provides the following methods to convert a Date object to a string object of a specified pattern, resolving a string date time to a DateTime object in the specified mode
2. Provides a numeric tool class that provides the following methods for converting a number to a string object of a specified pattern, resolving a string number to a number according to a specified pattern
3, Color Ball
4, login from the text read user name: admin Password: admin verification code to do comparison

Javase Study Notes: The eighth chapter of common Class Util Toolkit date class, digital class

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.