java-计算当前时间的前第几天前的GMT日期

package com.learn.utils;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.TimeZone;

public class DateTimeUtils {

	public static String getPreviousGMTDate(Integer days) {
		Calendar calendar1 = Calendar.getInstance();
	    SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
	    sdf1.setTimeZone(TimeZone.getTimeZone("GMT"));
	    calendar1.add(Calendar.DATE, -days);
	    String previous_days_date = sdf1.format(calendar1.getTime());
	    return previous_days_date;
	}
	
	public static void main(String[] args) {
		String date = getPreviousGMTDate(7);
		System.out.println(date);
	}
	
	
	
}

 

你可能感兴趣的:(java-计算当前时间的前第几天前的GMT日期)