Always use the time and date of some processing, such as: The time interval of a program, date time format ... Remark of
Time and date class commonly used in Java:
Java.util.Date
Java.util.Calendar
Java.text.DateFormat
Java.text.SimpleDateFormat
There is also a way to get the system time System.currenttimemillis ();
In Android:
Android.os.SystemClock
Android.text.format.DateFormat
Android.text.format.DateUtils
Android.os.SystemClock
Systemclock.elapsedrealtime (); How long after the phone starts (milliseconds, including the phone's deep sleep time)
So-called Android deep Sleep, that is, after the screen is off, do nothing for a while, do not connect the USB, and then after a certain time,
Mobile phone Many services, processes are sleep, no longer run.
Systemclock.uptimemillis (); How long after the phone has been activated (milliseconds, not including the phone's deep sleep time)
Systemclock.currentthreadtimemillis (); How much time the current thread is running (millisecond value, without thread or systemclock.sleep value)
Android.text.format.DateFormat
Dateformat.format ("Yyyy-mm-dd HH:mm:ss", System.currenttimemillis ());
Dateformat.format ("Yy/mm/dd", Calendar.getinstance ());
Dateformat.format ("yyyy", new Date (2048,12,01));
Direct according to format, format time (about format, definition in class)
Android.text.format.DateUtils
Dateutils.formatdatetime (Getapplicationcontext (),//format time, maximum display to minutes. Format of the final parameter setting display
System.currenttimemillis (),
dateutils.format_24hour| dateutils.format_show_date| Dateutils.format_show_time
| dateutils.format_show_year| Dateutils.length_long| Dateutils.format_abbrev_month);
Dateutils.getrelativetimespanstring (System.currenttimemillis () +60*4000));
Returns the string represented by the maximum interval relative to the current time: several (minutes, hours, days, weeks, months, years) before/after
Dateutils.getrelativetimespanstring (context, long timemillis);
Returns the parameter time string relative to the current time: displayed on the same day, on different days, showing the day of the month, in different year, showing the date
Dateutils.formatdaterange (Getapplicationcontext (), System.currenttimemillis (), System.currenttimemillis () + 60 * 60 * 3000,
Dateutils.format_show_time)); Returns the distance between two time values of a string
Android time, date processing dateutils, Systemclock, DateFormat