String Class: Immutable sequence of characters (for example: String str = "Atguigu"; str + = "java ee")
1. Focus on the usual methods of string!
2.String classes and basic data types, wrapper classes, and character arrays, byte arrays;
* 1. Conversion between string and base data type, wrapper class
*① String---> Basic data type, wrapper class: Call the corresponding wrapper classparsexxx (String str);
*① basic data types, wrapper classes---> Strings: Overloads of the calling stringvalueOf ()Method
*
* 2. Conversion between a string and a byte array
*① string----> byte array: GetBytes () of the calling string
*② byte array----> string: constructor that invokes a string
*
* 3. Conversion between a string and a character array
*① string----> Character array: ToCharArray () that invokes the string;
*② character array----> string: constructor that invokes a string
Conversion of 4.String to StringBuffer
①string--->stringbuffer: constructor with StringBuffer: New StringBuffer (String str);
②stringbuffer----->string: Using the ToString () method of StringBuffer
StringBuffer class: Variable sequence of characters
StringBuilder class: Variable sequence of characters, jdk5.0 new, more efficient, thread insecure.
Common methods: Add: Append (...) remove delete (int startIndex, int endIndex) Modify: Setcharat (int n, char ch) query: charAt (int index)
Insert: Insert (int index, String str) reverse reverse () Length: Length ()
2. Time and Date class:
2.1System class Currenttimemillis (): Returns a Long value for the current time. This long value starts from January 1, 1970 0:0 00 seconds to the current number of milliseconds.
This method is commonly used to calculate the time difference.
2.2 Date class: Java.util.Date
1. Date d = new Date ();//Returns the current time of Date:mon 15:17:01 CST 2014
Date D1 = new Date (15231512541241L);//return parameter at which the Long value corresponds
GetTime (): Returns the Long value corresponding to the current date. ToString ()
2.3simpledateformat:java.text.simpledateformat
Formatting: Date---> Text using the Format () method of SimpleDateFormat
Parsing: Text---> Dates using SimpleDateFormat's Parse () method
1. Formatting 1
SimpleDateFormat SDF = new SimpleDateFormat ();
String date = Sdf.format (new date ());
SYSTEM.OUT.PRINTLN (date);
2. Formatting 2
SimpleDateFormat sdf1 = new SimpleDateFormat ("EEE, D MMM yyyy HH:mm:ss Z");
Date = Sdf1.format (new date ());
SYSTEM.OUT.PRINTLN (date);
3. Analysis:
Date date1 = Sdf.parse ("17-7-21 3:24");
System.out.println (date1);
Date1 = Sdf1.parse ("Monday, 125 months 2014 15:29:16 +0800");
Date1 = Sdf1.parse ("14-5-12 3:24");
System.out.println (date1);
2.4 Calendar: Calendars class
2.4.1 Get instance: Calendar c = calendar.getinstance ();
2.4.2 Get ()/set ()/add ()/date getTime ()/settime ()
3.Math class
Java Common Classes