List of usage examples for java.util Calendar add
public abstract void add(int field, int amount);
From source file:Main.java
public static String getDateYYYYMM(int offset) { Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.MONTH, offset); return calendar.get(Calendar.YEAR) + "-" + calendar.get(Calendar.MONTH); }
From source file:Main.java
public static Calendar getTimeAfterInSecs(int secs) { Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.SECOND, secs); return calendar; }
From source file:Main.java
public static Calendar getNowCalendar(int afterDay) { Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DAY_OF_MONTH, afterDay); return calendar; }
From source file:Main.java
public static void addCalendarMillisecond(Calendar cal, int milliseconds) { cal.add(Calendar.MILLISECOND, milliseconds); }
From source file:Main.java
public static String getFormatDate(int step) { Calendar cal = Calendar.getInstance(); cal.add(Calendar.DATE, step); SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd"); String str = sf.format(cal.getTime()); return str;//from w w w. j av a 2s . com }
From source file:Main.java
public static long getMinTimeStampForIgMedia() { Calendar rightNow = Calendar.getInstance(); rightNow.add(Calendar.DAY_OF_YEAR, -2); return rightNow.getTimeInMillis() / 1000; }
From source file:Main.java
private static Date get6DaysAgo() { Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DATE, -6); return calendar.getTime(); }
From source file:Main.java
public static Calendar addMonthToDate(Calendar data, int quantidade) { Calendar dataRetorno = (Calendar) data.clone(); dataRetorno.add(Calendar.MONTH, quantidade); return dataRetorno; }
From source file:Main.java
public static String getDeadTime(int unit, int amount) { Calendar nowTime = Calendar.getInstance(); nowTime.add(unit, amount); nowTime.add(Calendar.HOUR_OF_DAY, 8); return new SimpleDateFormat("yyyyMMddHHmmssSSS").format(nowTime.getTime()); }
From source file:Main.java
private static Date get3HoursAgo() { Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.HOUR, -3); return calendar.getTime(); }