Android Get system time Yyyymmddhhmmsssss

Source: Internet
Author: User
Tags date1

Code Changes the world

Public String testTime1 () throws ParseException {String Default_time_format = "Yyyy-mm-dd ' T ' HH:mm:ss.        Sssz ";        Format the time//YYYY-MM-DD 1969-12-31//YYYY-MM-DD 1970-01-01               YYYY-MM-DD hh:mm 1969-12-31 16:00//YYYY-MM-DD hh:mm 1970-01-01 00:00//        YYYY-MM-DD hh:mmz 1969-12-31 16:00-0800//yyyy-mm-dd hh:mmz 1970-01-01 00:00+0000 Yyyy-mm-dd HH:mm:ss. SSSZ 1969-12-31 16:00:00.000-0800//Yyyy-mm-dd HH:mm:ss. SSSZ 1970-01-01 00:00:00.000+0000//yyyy-mm-dd ' T ' HH:mm:ss. SSSZ 1969-12-31t16:00:00.000-0800//yyyy-mm-dd ' T ' HH:mm:ss. SSSZ 1970-01-01t00:00:00.000+0000//Note: HH shows a 24-hour system, HH shows a 12-hour system SimpleDateFormat Dateformatter = new Simpledat        Eformat (Default_time_format); String datestr = Dateformatter.format (Calendar.getinstance (). GetTime ());//Get current time SimpleDateFormat DFF = new SimpleDateFormat ("Yyyy-mm-dd ' T ' HH:mm:ss.         SSS ", locale.english);//input converted time format SimpleDateFormat df1 = new SimpleDateFormat (" Yyyy-mm-dd HH:mm:ss ");//time format to convert to        SimpleDateFormat DF2 = new SimpleDateFormat ("Yyyymmddhhmmsssss");        Date date1 = Dff.parse (DATESTR);        String str1 = Df1.format (date1);        String str2 = Df2.format (date1);    return str2; }

  

The result returned is the YYYYMMDDHHMMSSSS 16-bit example: 2018030113443332 hh and HH differ in that one is 24 hours and one is 12 hours

  

Android Get system time Yyyymmddhhmmsssss

Related Article

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.