- import java.util.Calendar;
- import java.util.TimeZone;
-
- public class Test1 {
-
- public static void main(String[] args) {
-
-
- Calendar cc = Calendar.getInstance(TimeZone.getTimeZone("GMT+8"));
- int year = cc.get(Calendar.YEAR);
-
-
- int month = cc.get(Calendar.MONTH)+1;
- int day = cc.get(Calendar.DAY_OF_MONTH);
-
- int hour_8 = cc.get(Calendar.HOUR);
- int hour_24 = cc.get(Calendar.HOUR_OF_DAY);
-
- int minute = cc.get(Calendar.MINUTE);
- int second = cc.get(Calendar.SECOND);
-
-
- int weekday = cc.get(Calendar.DAY_OF_WEEK)-1;
-
-
- System.out.println(year+"-"+month+"-"+day+" "+hour_8+":"+minute+":"+second+" 星期"+weekday);
-
-
- System.out.println(year+"-"+month+"-"+day+" "+hour_24+":"+minute+":"+second+" 星期"+weekday);
- }
- }
输出结果:
- 2012-3-16 3:24:24 星期5
- 2012-3-16 15:24:24 星期5
安卓时间戳(一),布布扣,bubuko.com
安卓时间戳(一)
原文:http://www.cnblogs.com/lucky-star-star/p/3900019.html