Here you can find the source of getYYYY_MM_DD(int offsetDays)
public static String getYYYY_MM_DD(int offsetDays)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { private final static ThreadLocal<SimpleDateFormat> YYYY_MM_DD_FORMAT = new ThreadLocal<SimpleDateFormat>() { @Override/*from www . j a v a 2 s . co m*/ protected SimpleDateFormat initialValue() { return new SimpleDateFormat("yyyy-MM-dd"); } ; }; public static String getYYYY_MM_DD(int offsetDays) { Calendar calendar = Calendar.getInstance(); if (offsetDays != 0) calendar.add(Calendar.DATE, offsetDays); Date date = calendar.getTime(); return formatDD(date); } /** * yyyy-MM-dd * * @param date * @return */ public static String formatDD(Date date) { return YYYY_MM_DD_FORMAT.get().format(date); } }