The following conversions are from Java, but are also available in Android. (The contents of the table below are from the Internet.)Common date format conversion characters
| Conversion character |
Description |
Example |
| %te |
One day in one months (1~31) |
2 |
| %tb |
Specify the month abbreviation for the locale |
Feb (English), February (Chinese) |
| %tb |
Specify the full month name of the locale |
February (English), February (Chinese) |
| %ta |
Specify the day of the week for the locale |
Monday (English), Monday (Chinese) |
| %ta |
Specify the weekday abbreviation for the locale |
Mon (English), Monday (Chinese) |
| %tc |
Include all date and time information |
Week April or January 10:26:30 CST 2009 |
| %ty |
4-bit year |
2009 |
| %tj |
The first day of the Year (001~366) |
085 |
| %tm |
Month |
03 |
| %td |
Day of the one months (01~31) |
08 |
| %ty |
2-bit year |
09 |
time-formatted conversion characters
| Conversion character |
Description |
Example |
| %th |
2-digit 24-hour hour (00~23) |
14 |
| %ti |
2-digit 12-hour hour (01~12) |
05 |
| %tk |
2-digit 24-hour hour (1~23) |
5 |
| %tl |
2-digit 12-hour hour (1~12) |
10 |
| %tm |
2-digit minute (00~59) |
05 |
| %ts |
Number of seconds in 2 digits (00~60) |
12 |
| %tl |
Number of milliseconds in 3 digits (000~999) |
920 |
| %tn |
Number of microseconds in 9 digits (000000000~999999999) |
062000000000 |
| %tp |
Specify the language environment for the morning or afternoon mark |
Afternoon (Chinese), PM (English) |
| %tz |
Digital time zone offset relative to GMT RFC 82 format |
+0800 |
| %tz |
A string in the form of a time zone abbreviation |
Cst |
| %ts |
1970-01-01 00:00:00 to now the number of seconds elapsed |
1206426646 |
| %tq |
1970-01-01 00:00:00 to now the number of milliseconds elapsed |
1206426737453 |
Common Date-time combination conversions
| translator |
description |
example |
| %TF |
"year- Month-day format (4-bit year) |
2009-01-26 |
| %td |
"Month/ Day/year format (2-bit year) |
03/25/09 |
| %tr |
": Seconds PM (AM) format (12-hour) |
03:22:06 pm |
| %tt |
&N BSP; " Time: minutes: Seconds "format (24-hour) |
15:23:50 |
| %tr |
" : Sub "format (24-hour) |
15:23 |
An example of a date conversion, Mydateformat.java
Package Com.yusuzhan.criminalintent.util;import Java.util.date;public class Mydateformat {public static String Mydateformat (date date) {string dateday = String.Format ("%ta", date);//week String Datemon = String.Format ("%TB", date);// Month String datedayofmonth = String.Format ("%te", date); The day of the one month String dateyear = String.Format ("%ty", date); Year string s = Dateday + "," + Datemon + "" + Datedayofmonth + "," + dateyear;//System.out.println (s); return s;}}
Android Notes: Date formatting