在Gmt + 530分钟内添加分钟

时间:2013-07-04 06:11:15

标签: java android date gmt

我想在gmt时间内添加分钟。

我通过使用此方法获得gmt时间。

new Date().toGMTString();

如何在最终结果日期将此结果转换为分钟?

我怎样才能添加分钟?

由于

3 个答案:

答案 0 :(得分:1)

一种方法是使用Calendar

public Date addMinute(Date date, int minuteToAdd) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        cal.add(Calendar.MINUTE, minuteToAdd);
            return cal.getTime();
}

答案 1 :(得分:0)

您可以先添加分钟,然后再获取GMT字符串

Calendar calendar = Calendar.getInstance();

// add the minutes
calendar.add(Calendar.MINUTE, 12);

// now obtain the date
Date date = calendar.getTime();

System.out.println(date.toGMTString());

请注意,因为toGMTString()已被弃用。请考虑使用SimpleDateFormat代替

答案 2 :(得分:0)

你可以这样做:

Date temp = new Date().toGMTString();
Date newDate=new Date(temp + (530 * 60000));