/*
* Copyright Massimiliano Dess� (desmax74@yahoo.it)
*
* Licensed under Apache License Version 2.0
* (http://www.apache.org/licenses/LICENSE-2.0),
*
* for commercial use, under
* GNU General Public License Version 2 or later (the "GPL")
* http://www.gnu.org/licenses/gpl.html
*/
package org.magicbox.util;
import java.text.SimpleDateFormat;
import org.joda.time.DateTime;
import org.joda.time.Period;
import org.joda.time.ReadablePeriod;
/**
* Classe di utilit� per le date
*
* @author Massimiliano Dess� (desmax74@yahoo.it)
* @since jdk 1.6.0
* @version 3.0
*/
public class TimeDateUtils {
public static String getDataNextMesi(int numeroMesi) {
DateTime now = new DateTime();
ReadablePeriod noUpdatePeriod = new Period().withMonths(numeroMesi);
return now.plus(noUpdatePeriod).toString();
}
public static String getDataNextMesiFormattata(int numeroMesi, String regexp) {
DateTime now = new DateTime();
ReadablePeriod noUpdatePeriod = new Period().withMonths(numeroMesi);
return new SimpleDateFormat(regexp).format(now.plus(noUpdatePeriod).toDate());
}
public static String getDataPreviousMesi(int numeroMesi) {
DateTime now = new DateTime();
ReadablePeriod noUpdatePeriod = new Period().withMonths(numeroMesi);
return now.minus(noUpdatePeriod).toString();
}
public static String getDatapreviousMesiFormattata(int numeroMesi, String regexp) {
DateTime now = new DateTime();
ReadablePeriod noUpdatePeriod = new Period().withMonths(numeroMesi);
return new SimpleDateFormat(regexp).format(now.minus(noUpdatePeriod).toDate());
}
}