获取时间的三种方法
1.SimpleDateFormat sDateFormat = new SimpleDateFormat( "yyyyMMddhhmmss" );
String date = sDateFormat.format( new java.util.Date( ));
2.
Time time = new Time( "GMT+8" ); time.setToNow(); int year = time.year; int month = time.month; int day = time.monthDay; int minute = time.minute; int hour = time.hour; int sec = time.second; myTextView.setText("当前时间为:" + year + "年 " + month + "月 " + day + "日 " + hour + "时 " + minute + "分 " + sec + "秒" );
3,
Calendar c = Calendar.getInstance(); 取得系统日期:year = c.get(Calendar.YEAR) month = c.grt(Calendar.MONTH) day = c.get(Calendar.DAY_OF_MONTH) 取得系统时间:hour = c.get(Calendar.HOUR_OF_DAY); minute = c.get(Calendar.MINUTE) Calendar c = Calendar.getInstance(); 取得系统日期:year = c.get(Calendar.YEAR) month = c.grt(Calendar.MONTH) day = c.get(Calendar.DAY_OF_MONTH) 取得系统时间:hour = c.get(Calendar.HOUR_OF_DAY); minute = c.get(Calendar.MINUTE)
获取延迟20分钟的时间
SimpleDateFormat sDateFormat = new SimpleDateFormat("yyyyMMddhhmmss" );
String date = sDateFormat.format( new java.util.Date(System. currentTimeMillis () + 20 * 60 * 1000 ));