|
Time t = new time (); // or time t = new time ("GMT + 8"); plus the time zone information.
T. settonow (); // obtain the system time.
Int year = T. Year;
Int month = T. month;
Int date = T. monthday;
Int hour = T. hour; // 0-23
Int minute = T. minute;
Int second = T. Second;
Int time = integer. parseint ("15 ");
String Shour = ("" + time. hour );
String. valueof ();
Stest. compareto (stest2 );
| Use Java to determine whether the string is of the daily date type (Regular Expression) public static Boolean checkstrformat (string Str ){
Pattern pattern = pattern. compile ("^ ([0-9] {4}) (0 ([1-9] {1}) | (1 [0-2]) ([0-2] ([0-9] {1}) | (3 [0 | 1]) ([0-1] ([0-9] {1}) | (2 [0-4]) ([0-5] ([0-9] {1}) ([0-5] ([0-9] {1 }))");
/// Pattern = pattern. Compile ("[0-9] {2}: [0-9] {2 }");
Matcher = pattern. matcher (STR );
Boolean bool = matcher. Matches ();
Return bool;
} |
|
Pattern pattern = pattern. compile ("^ ([0-9] {4}) (0 ([1-9] {1}) | (1 [0-2]) ([0-2] ([0-9] {1}) | (3 [0 | 1]) ([0-1] ([0-9] {1}) | (2 [0-4]) ([0-5] ([0-9] {1}) ([0-5] ([0-9] {1 }))");
/// Pattern = pattern. Compile ("[0-9] {2}: [0-9] {2 }");
Matcher = pattern. matcher (STR );
Boolean bool = matcher. Matches ();
Return bool;
}