Date:
1 CST:2Date d =NewDate ();3 Dateformat:simpledateformat:4 5String str = "Yyyy-mm-dd HH:mm:ss E";6SimpleDateFormat SDF =NewSimpleDateFormat ();7 Sdf.applypattern (str);8 9 //Date--> String time FormattingTenString d = Sdf.format (NewDate ()); One A //String--- date parse the time back -Date d = sdf.parse (d);
Calendar:
1 abstract class: Calendar getinstance ();2 //The value of field is the constant in the Calendar class:3 intGetintfield): Gets the value of the specified field4 calendar.year;5 . MONTH;6 . DATE;7. Hour_of_day;//24 binary (. HOUR; 12 binary)8 . MINUTE;9 . SECOND;Ten One use StringBuilder to spell a current system time; A -Calendar C =calendar.getinstance (); -C.settime (NewDate ()); the -StringBuilder SB =NewStringBuilder ("MYCST:"); - - inty =C.get (calendar.year); + intm = C.get (calendar.month) + 1; - intD =C.get (calendar.date); + inth =C.get (calendar.hour_of_day); A intMM =C.get (calendar.minute); at ints =C.get (calendar.second); - -Sb.append (y). Append ("Year"). Append (M). Append ("Month");......; - - voidsettime (Date D); - Date getTime (); in - /* to offset of field value + */ - voidAddintFiledintoffset); the if offset is negative: indicates that the field value represented by the filed is shifted forward by offset; * If offset is a positive number: Indicates that the field value represented by the filed is shifted back offset; $ Panax NotoginsengSetintfield,intval): Set a value for a field -SetintYearintMonintDateintHourintMinints); the +Time period settings: last two days; 2015-8-6:10:24:11 A theStart Time Begintime:2015-8-5:00:00:00 +End Time Endtime:2015-8-6:23:59:59 - $(Querytime >= beginTime) && (querytime <= endTime)
System:
void Arraycopy (object src, int pos, object dest, int destpos, int length);
void exit (int status);
System exit:
Always exit: System.exit (0);
1 means to meet an abnormal exit
To force garbage collection: void GC ();
void GC ();
static string getenv (string name)
Gets the specified environment variable value.
Runtime:
Process exec (String command)
Executes the specified string command in a separate process.
Runtime.getruntime (). EXEC ("notepad.exe Ooxx.java");
means to open the Ooxx.java file in Notepad
Regular Expressions:
belongs to the Java.util.regex package;
Pattern: Presentation Specification
Matcher: Represents the execution specification
String input = "data to be judged";
String regex = "Specification";
Pattern p = pattern.compile (regex);
Matcher m = p.matcher (Charsequence CS);
Boolean B = m.matches ();
Static Boolean matches (String regex, charsequence input)
---------------------------------
b = pattern.matches (regex,input);
---------------------------------
String class:
Boolean matches (String regex) {
Return pattern.matches (Regex,this);
}
Boolean B = input.matches (regex);
There are two ways to create a startup thread:
1. How to Inherit
(1). Create a new class MyThread inherit Java.lang.Thread
(2). Overwrite public void Run () {}
(3). Create thread: MyThread t = new MyThread ();
(4). Start thread: T.start ();
2. Implementation method (recommended), using anonymous inner class to create
(1). Create a new class myrunnable implement Java.lang.Runnable interface
(2). Implement public void Run () {}
(3). Create thread: Thread t = new Thread (new myrunnable ());
(4). Start thread: T.start ();
the difference between the two: the inheritance mode of resources can not be shared, and later can not inherit other classes; Advantages: Simple.
Common methods:
String GetName ();
void SetName ();
Thread t = Thread.CurrentThread ();
Thread ();
Thread (String name);
Thread (Runnable target);
Thread (Runnable target, String name);
2015-08-06 Common Classes 2, regular expressions, threading