Here you can find the source of getUpMonthDate(String date, String dateFormat)
public static Date getUpMonthDate(String date, String dateFormat)
//package com.java2s; /*/* www .ja va 2 s. c o m*/ * Copyright 1998-2012 360buy.com All right reserved. This software is the confidential and proprietary information of * 360buy.com ("Confidential Information"). You shall not disclose such Confidential Information and shall use it only * in accordance with the terms of the license agreement you entered into with 360buy.com. */ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main { public static Date getUpMonthDate(String date, String dateFormat) { Calendar c = new GregorianCalendar(); c.setTime(strToDate(date, dateFormat)); c.add(Calendar.MONTH, -1); return c.getTime(); } public static Date strToDate(String dateStr, String formatStr) { Date date = null; if (dateStr != null && !"".equals(dateStr)) { SimpleDateFormat sdf = new SimpleDateFormat(formatStr); try { date = sdf.parse(dateStr); } catch (ParseException e) { e.printStackTrace(); } } return date; } }