List of usage examples for java.util Calendar setLenient
public void setLenient(boolean lenient)
From source file:com.aurel.track.report.dashboard.StatusOverTimeGraph.java
public static String createRegularTimePeriodForJSON(int period, int year, int timeInterval) { Calendar calendar = Calendar.getInstance(); SimpleDateFormat dateFormat;//from w ww .j a va2s . c o m switch (timeInterval) { case TIME_INTERVAL.DAY: calendar.setLenient(true); calendar.clone(); calendar.set(Calendar.YEAR, year); calendar.set(Calendar.DAY_OF_YEAR, period); dateFormat = new SimpleDateFormat("yyyy-MM-dd"); return dateFormat.format(calendar.getTime()); case TIME_INTERVAL.WEEK: return period + "/" + year; default: period++; if (period < 10) { return year + "-0" + period; } else { return year + "-" + period; } } }
From source file:com.clustercontrol.jobmanagement.factory.JobPlanSchedule.java
/** * ?????//from ww w . j ava 2s . c om * @param year * @param month * @param day * @return */ private boolean isDate(int year, int month, int day) { boolean ret = false; Calendar cal = HinemosTime.getCalendarInstance(); cal.setLenient(true); cal.set(year, month - 1, day); ret = cal.get(Calendar.MONTH) == (month - 1) % 12; m_log.trace("year=" + year + ",month=" + month + ",day=" + day + ",ret=" + ret); return ret; }
From source file:org.surfnet.cruncher.repository.StatisticsRepositoryImpl.java
private Calendar createRetentionTime(int retention) { SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy"); Calendar retentionTime = new GregorianCalendar(); retentionTime.setLenient(true); retentionTime.add(Calendar.MONTH, -retention); LOG.debug("Cleaning tables to date " + sdf.format(retentionTime.getTime())); return retentionTime; }
From source file:DateParser.java
/** * /* w w w .j ava 2s.com*/ * @param iso8601DateAsString The date parameter as a String. * @return The corresponding Date object representing the result of parsing the date parameter. * @throws InvalidDateException In case of an invalid date. */ public Date parse(String iso8601DateAsString) throws InvalidDateException { Calendar calendar = getCalendar(iso8601DateAsString); try { calendar.setLenient(false); return calendar.getTime(); } catch (Exception e) { throw new InvalidDateException( iso8601DateAsString + " " + e.getClass().toString() + " " + e.getMessage()); } }
From source file:jp.co.ctc_g.jfw.core.util.Dates.java
/** * ????????//from www. jav a 2 s .com * @param year * @param month * @param day * @param hourOfDay * @param minute * @param second * @param millis * @return */ public static Date makeFrom(int year, int month, int day, int hourOfDay, int minute, int second, int millis) { Calendar calendar = Calendar.getInstance(); calendar.setLenient(true); calendar.set(year, month - 1 /* zero origin */, day, hourOfDay, minute, second); calendar.set(Calendar.MILLISECOND, millis); return calendar.getTime(); }
From source file:jp.co.ctc_g.jfw.core.util.Dates.java
/** * ????/*w w w. j av a2s . c o m*/ * @param date ?? * @return */ public static int getYear(Date date) { if (date == null) return -1; Calendar calendar = Calendar.getInstance(); calendar.setLenient(true); calendar.setTime(date); return calendar.get(Calendar.YEAR); }
From source file:jp.co.ctc_g.jfw.core.util.Dates.java
/** * ????//w w w . j a v a 2 s . co m * ?????1???1??2???2???? * @param date ?? * @return */ public static int getMonth(Date date) { if (date == null) return -1; Calendar calendar = Calendar.getInstance(); calendar.setLenient(true); calendar.setTime(date); return calendar.get(Calendar.MONTH) + 1; }
From source file:jp.co.ctc_g.jfw.core.util.Dates.java
/** * ????//from ww w . j a v a2 s . c om * @param date ?? * @return */ public static int getDay(Date date) { if (date == null) return -1; Calendar calendar = Calendar.getInstance(); calendar.setLenient(true); calendar.setTime(date); return calendar.get(Calendar.DAY_OF_MONTH); }
From source file:jp.co.ctc_g.jfw.core.util.Dates.java
/** * ????/*from ww w . j av a 2s. com*/ * @param date ?? * @return */ public static int getDayOfWeek(Date date) { if (date == null) return -1; Calendar calendar = Calendar.getInstance(); calendar.setLenient(true); calendar.setTime(date); return calendar.get(Calendar.DAY_OF_WEEK); }
From source file:jp.co.ctc_g.jfw.core.util.Dates.java
/** * ????/*from www . java 2s .co m*/ * @param date ?? * @return ?? */ public static Date nextYear(Date date) { if (date == null) return null; Calendar calendar = Calendar.getInstance(); calendar.setLenient(true); calendar.setTime(date); calendar.add(Calendar.YEAR, 1); return calendar.getTime(); }