Search in sources :

Example 41 with Calendar

use of java.util.Calendar in project head by mifos.

the class DateUtils method getFistDayOfNextYear.

public static Calendar getFistDayOfNextYear(Calendar cal) {
    cal.roll(Calendar.YEAR, 1);
    cal.set(Calendar.MONTH, Calendar.JANUARY);
    cal.set(Calendar.DAY_OF_MONTH, cal.getActualMinimum(Calendar.DATE));
    Calendar cal1 = new DateTimeService().getCurrentDateTime().toGregorianCalendar();
    cal1.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DATE), 0, 0, 0);
    return cal1;
}
Also used : GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) DateTimeService(org.mifos.framework.util.DateTimeService)

Example 42 with Calendar

use of java.util.Calendar in project head by mifos.

the class DateUtils method getLastDayOfNextYear.

public static Date getLastDayOfNextYear() {
    Calendar cal = getCurrentDateCalendar();
    cal.set(Calendar.MONTH, Calendar.DECEMBER);
    cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DATE));
    Calendar cal1 = getCurrentDateCalendar();
    cal1.set(cal.get(Calendar.YEAR) + 1, cal.get(Calendar.MONTH), cal.get(Calendar.DATE), 0, 0, 0);
    return cal1.getTime();
}
Also used : GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar)

Example 43 with Calendar

use of java.util.Calendar in project head by mifos.

the class DateUtils method sameMonthYear.

public static boolean sameMonthYear(Date firstDate, Date secondDate) {
    Calendar first = Calendar.getInstance();
    first.setTime(firstDate);
    Calendar second = Calendar.getInstance();
    second.setTime(secondDate);
    return sameMonthYear(first, second);
}
Also used : GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar)

Example 44 with Calendar

use of java.util.Calendar in project head by mifos.

the class DateUtils method getLastDayOfCurrentYear.

public static Date getLastDayOfCurrentYear() {
    Calendar cal = getCurrentDateCalendar();
    cal.set(Calendar.MONTH, Calendar.DECEMBER);
    cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DATE));
    Calendar cal1 = getCurrentDateCalendar();
    cal1.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DATE), 0, 0, 0);
    return new Date(cal1.getTimeInMillis());
}
Also used : GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) Date(java.util.Date) LocalDate(org.joda.time.LocalDate)

Example 45 with Calendar

use of java.util.Calendar in project head by mifos.

the class DateUtils method getNumberOfDaysBetweenTwoDates.

public static long getNumberOfDaysBetweenTwoDates(Date date1, Date date2) {
    Calendar cal1 = getCurrentDateCalendar();
    Calendar cal2 = getCurrentDateCalendar();
    cal1.setTime(getDateWithoutTimeStamp(date1));
    cal2.setTime(getDateWithoutTimeStamp(date2));
    return ((cal1.getTime().getTime() - cal2.getTime().getTime()) / (24 * 60 * 60 * 1000));
}
Also used : GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar)

Aggregations

Calendar (java.util.Calendar)9441 Date (java.util.Date)2433 GregorianCalendar (java.util.GregorianCalendar)2129 Test (org.junit.Test)1734 SimpleDateFormat (java.text.SimpleDateFormat)889 ArrayList (java.util.ArrayList)476 ParseException (java.text.ParseException)352 HashMap (java.util.HashMap)270 TimeZone (java.util.TimeZone)270 IOException (java.io.IOException)235 DateFormat (java.text.DateFormat)224 Timestamp (java.sql.Timestamp)192 List (java.util.List)187 File (java.io.File)167 Map (java.util.Map)149 BigDecimal (java.math.BigDecimal)134 Locale (java.util.Locale)134 Test (org.testng.annotations.Test)118 Identity (org.olat.core.id.Identity)112 Date (java.sql.Date)110