Here you can find the source of getDate(String aDate, int dif)
public static String getDate(String aDate, int dif)
//package com.java2s; /**/*w ww . java 2s. c om*/ * $RCSfile: DateUtil.java * $Revision: 1.0 * $Date: Jan 30, 2011 * * Copyright (C) 2010 SlFile, Inc. All rights reserved. * * This software is the proprietary information of SlFile, Inc. * Use is subject to license terms. */ import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { public static String getDate(String aDate, int dif) { java.sql.Date date = null; try { date = java.sql.Date.valueOf(aDate); } catch (Exception e) { System.err.println("Application log:Catch Exception in getDate()"); System.err.println("aDate:" + aDate); System.err.println(e.getMessage()); e.printStackTrace(); return null; } Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendar.add(5, dif); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); String s = df.format(calendar.getTime()); return s; } }