Here you can find the source of getSetDate(Date dt, int dayNum)
public static String getSetDate(Date dt, int dayNum)
//package com.java2s; /******************************************************************************* * @FileName: helper.java 2013-7-12 ????4:13:15 * @Author: zhangzhia/*from w ww. j a va 2 s. com*/ * @Copyright: 2013 YUTONG Group CLW. All rights reserved. * @Remarks: YUTONG PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. *******************************************************************************/ import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static String getSetDate(Date dt, int dayNum) { StringBuffer str = new StringBuffer(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Calendar lastDate = Calendar.getInstance(); lastDate.add(Calendar.DATE, dayNum); str.append(sdf.format(lastDate.getTime())); return str.toString(); } }