Android gets the conversion between the current system time and time to determine whether the string is of the daily date type

Source: Internet
Author: User

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;
}

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.