Here you can find the source of addMonthTimetamp(long lTimeStamp, String _pattern, int month)
public static String addMonthTimetamp(long lTimeStamp, String _pattern, int month)
//package com.java2s; import java.util.*; import java.text.*; public class Main { public static String addMonthTimetamp(long lTimeStamp, String _pattern, int month) { Date date = new Date(lTimeStamp); Calendar cal = Calendar.getInstance(); cal.setTime(date);/*from www.j av a 2 s . co m*/ int y = cal.get(Calendar.YEAR); int m = cal.get(Calendar.MONTH); int d = cal.get(Calendar.DATE); cal.set(y, m + month, d); Date addMonth = cal.getTime(); SimpleDateFormat formatter = new SimpleDateFormat(_pattern); String addMonthStr = formatter.format(addMonth); return addMonthStr; } public static Date getTime(String hhmm) { if (hhmm != null && hhmm.length() == 4 && isDigit(hhmm)) { Calendar cal = Calendar.getInstance(); cal.set(Calendar.HOUR_OF_DAY, Integer.parseInt(hhmm.substring(0, 2))); cal.set(Calendar.MINUTE, Integer.parseInt(hhmm.substring(2, 4))); return cal.getTime(); } return null; } private static boolean isDigit(String digitStr) { if (digitStr != null) { for (int i = 0; i < digitStr.length(); i++) if (!Character.isDigit(digitStr.charAt(i))) return false; } return true; } }