原地址:http://blog.csdn.net/chaoyu168/article/details/50729689
方式一:
- import java.text.SimpleDateFormat;
- SimpleDateFormat formatter = new SimpleDateFormat ("yyyy年MM月dd日 HH:mm:ss");
- Date curDate = new Date(System.currentTimeMillis());
-
- String str = formatter.format(curDate);
方式二:
- 取得系统时间
- 1。
- long time=System.currentTimeMillis();
-
- 2。
- final Calendar mCalendar=Calendar.getInstance();
- mCalendar.setTimeInMillis(time);
- 取得小时:mHour=mCalendar.get(Calendar.HOUR);
- 取得分钟:mMinuts=mCalendar.get(Calendar.MINUTE);
-
-
- 3。
- Time t=new Time();
- t.setToNow();
- int year = t.year;
- int month = t.month;
- int date = t.monthDay;
- int hour = t.hour;
-
- 4。
- DateFormat df = new SimpleDateFormat("HH:mm:ss");
- df.format(new Date());