List of usage examples for java.util Date getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:jp.co.ctc_g.jfw.core.util.Dates.java
/** * ????????.//from ww w . j a v a 2s .c o m * @param date ? * @param inclement ?.????????. * @return ?? */ public static Date addMinute(Date date, int inclement) { if (inclement == 0) { return date; } Calendar currentCalendar = Dates.getCalendarInstance(date); int year = currentCalendar.get(Calendar.YEAR); int month = Dates.toRealMonth(currentCalendar.get(Calendar.MONTH)); int day = currentCalendar.get(Calendar.DATE); int hour = currentCalendar.get(Calendar.HOUR_OF_DAY); int minute = currentCalendar.get(Calendar.MINUTE); if (inclement >= 0) { for (int index = 0; index < inclement; index++) { minute++; if (minute >= 60) { minute = 0; hour++; if (hour >= 24) { hour = 0; day++; if (!enableDayOfMonth(year, month, day)) { day = 1; month++; if (month >= 13 || !enableDayOfMonth(year, month, day)) { month = 1; year++; } } } } } } else { for (int index = inclement; index < 0; index++) { minute--; if (minute < 0) { minute = 59; hour--; if (hour < 0) { hour = 23; day--; if (day <= 0) { month--; if (month <= 0) { year--; if (year <= 0) { throw new InternalException(Dates.class, "E-UTIL#0036"); } else { month = 12; day = DAY_OF_MONTH[11]; } } else { day = DAY_OF_MONTH[month - 1]; if (!isLeapYear(year) && month == 2) { day--; } } } } } } } currentCalendar.set(year, Dates.toCalendarMonth(month), day, hour, minute, currentCalendar.get(Calendar.SECOND)); long time = currentCalendar.getTimeInMillis(); /* * ???????????? Calendar????????java.util.Date??????? */ return instantiateDate(date.getClass(), time); }
From source file:jp.co.ctc_g.jfw.core.util.Dates.java
/** * ????????.// w ww . j a va2s . c om * @param date ? * @param inclement ?.????????. * @return ?? */ public static Date addSecond(Date date, int inclement) { if (inclement == 0) { return date; } Calendar currentCalendar = Dates.getCalendarInstance(date); int year = currentCalendar.get(Calendar.YEAR); int month = Dates.toRealMonth(currentCalendar.get(Calendar.MONTH)); int day = currentCalendar.get(Calendar.DATE); int hour = currentCalendar.get(Calendar.HOUR_OF_DAY); int minute = currentCalendar.get(Calendar.MINUTE); int second = currentCalendar.get(Calendar.SECOND); if (inclement >= 0) { for (int index = 0; index < inclement; index++) { second++; if (second >= 60) { second = 0; minute++; if (minute >= 60) { minute = 0; hour++; if (hour >= 24) { hour = 0; day++; if (!enableDayOfMonth(year, month, day)) { day = 1; month++; if (month >= 13 || !enableDayOfMonth(year, month, day)) { month = 1; year++; } } } } } } } else { for (int index = inclement; index < 0; index++) { second--; if (second < 0) { second = 59; minute--; if (minute < 0) { minute = 59; hour--; if (hour < 0) { hour = 23; day--; if (day <= 0) { month--; if (month <= 0) { year--; if (year <= 0) { throw new InternalException(Dates.class, "E-UTIL#0036"); } else { month = 12; day = DAY_OF_MONTH[11]; } } else { day = DAY_OF_MONTH[month - 1]; if (!isLeapYear(year) && month == 2) { day--; } } } } } } } } currentCalendar.set(year, Dates.toCalendarMonth(month), day, hour, minute, second); long time = currentCalendar.getTimeInMillis(); /* * ???????????? Calendar????????java.util.Date??????? */ return instantiateDate(date.getClass(), time); }
From source file:ca.oson.json.Oson.java
private Date date2Date(Date currentDate, Class returnType) { if (currentDate == null) { return currentDate; }/*from ww w . j av a 2 s. com*/ Class cls = currentDate.getClass(); if (returnType.isAssignableFrom(cls)) { return currentDate; } if (Date.class != returnType) { return date2Date(currentDate.getTime(), returnType); } else { return currentDate; } }