1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
取得系统时间
1.1
SimpleDateFormat formatter= new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss ");
Date curDate = new Date(System.currentTimeMillis());//获取当前时间 String str = formatter.format(curDate);
1.2
SimpleDateFormat sDateFormat=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
String date= sDateFormat.format(new Date());
1.3 单独获取年月或者时分
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM");
String date=sdf.format(new Date());
SimpleDateFormat sdf=new SimpleDateFormat("hh:mm:ss");
String date=sdf.format(new Date()); 2
final
Calendar mCalendar=Calendar.getInstance();
mCalendar.setTimeInMillis(time);
取得小时:mHour=mCalendar.get(Calendar.HOUR);
取得分钟:mMinuts=mCalendar.get(Calendar.MINUTE);
取得系统日期:
year = c.get(Calendar.YEAR)
3
Time t=
new
Time();
t.setToNow();// 取得系统时间。
|
Android 获取系统时间的三种方式
猜你喜欢
转载自blog.csdn.net/qq_22118507/article/details/51684304
今日推荐
周排行