android 获取当前时间,时间转字符串,字符串转时间

 时间字符串转时间
SimpleDateFormat dFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
	Date d1 = dFormat.parse("2014-03-24 13:31:42");
	ate d2 = dFormat.parse("2014-03-24 13:32:42");
	long l = d2.getTime() - d1.getTime();
	Log.d("time", "time"+l);
    } catch (Exception e) {
				// TODO: handle exception
			}

时间转字符串

Time time  =  new Time()

time.setToNow();

String str_time2 = time.format("%Y-%m-%d %H:%M:%S");

你可能感兴趣的:(android 获取当前时间,时间转字符串,字符串转时间)