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