您的位置:首页 > 移动开发 > Android开发

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

2014-11-29 12:36 134 查看
 时间字符串转时间
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");
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: