List of usage examples for java.util Calendar DAY_OF_MONTH
int DAY_OF_MONTH
To view the source code for java.util Calendar DAY_OF_MONTH.
Click Source Link
get
and set
indicating the day of the month. From source file:com.knowbout.epg.EPGServiceTest.java
public void testSchedules() { String lineupId = "CA04542:R"; String programId = "SH0000010000"; Calendar cal = Calendar.getInstance(); Date now = new Date(); cal.add(Calendar.DAY_OF_MONTH, -14); Date past = cal.getTime();//from w w w .j a va2 s . co m cal.setTime(now); cal.add(Calendar.DAY_OF_MONTH, 14); Date future = cal.getTime(); EPGProviderService service = new EPGProviderService(); List<ScheduledProgram> progs = service.getScheduleForProgram(lineupId, programId, past, future); for (ScheduledProgram prog : progs) { System.err.println("prog:" + prog.getEpisodeTitle() + ", " + prog.getStartTime() + " linup" + prog.getChannel().getChannel() + " title:" + prog.getProgramTitle()); } ScheduledProgram next = service.getNextShowing(lineupId, programId); System.err.println("Next:" + next.getEpisodeTitle() + ", " + next.getStartTime()); assertNotNull(next); ScheduledProgram last = service.getLastShowing(lineupId, programId); System.err.println("last:" + last.getEpisodeTitle() + ", " + last.getStartTime()); assertNotNull(last); }
From source file:com.eryansky.common.utils.DateUtil.java
/** * ? ?2009-08-01/*from www. j a va 2 s . com*/ */ public static String curDate() { // ??????? Calendar localTime = Calendar.getInstance(); int x = localTime.get(Calendar.YEAR); int y = localTime.get(Calendar.MONTH) + 1; int z = localTime.get(Calendar.DAY_OF_MONTH); return x + "-" + y + "-" + z; }
From source file:io.github.microcks.listener.DailyStatisticsFeeder.java
@Override public void onApplicationEvent(MockInvocationEvent event) { log.debug(//from w ww . j a v a 2s .c o m "Received a MockInvocationEvent on " + event.getServiceName() + " - v" + event.getServiceVersion()); // Compute day string representation. Calendar calendar = Calendar.getInstance(); calendar.setTime(event.getInvocationTimestamp()); // Computing keys based on invocation date. int month = calendar.get(Calendar.MONTH) + 1; String monthStr = (month < 10 ? "0" : "") + String.valueOf(month); int dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH); String dayOfMonthStr = (dayOfMonth < 10 ? "0" : "") + String.valueOf(dayOfMonth); String day = String.valueOf(calendar.get(Calendar.YEAR)) + monthStr + dayOfMonthStr; String hourKey = String.valueOf(calendar.get(Calendar.HOUR_OF_DAY)); String minuteKey = String .valueOf((60 * calendar.get(Calendar.HOUR_OF_DAY)) + calendar.get(Calendar.MINUTE)); if (log.isDebugEnabled()) { log.debug("hourKey for statistic is " + hourKey); log.debug("minuteKey for statistic is " + minuteKey); } // First check if there's a statistic document for invocation day. DailyStatistic statistic = statisticsRepository.findByDayAndServiceNameAndServiceVersion(day, event.getServiceName(), event.getServiceVersion()); if (statistic == null) { // No statistic's yet... log.debug("There's no statistics for " + day + " yet. Create one...."); // Initialize a new 0 filled structure. statistic = new DailyStatistic(); statistic.setDay(day); statistic.setServiceName(event.getServiceName()); statistic.setServiceVersion(event.getServiceVersion()); statistic.setHourlyCount(initializeHourlyMap()); statistic.setMinuteCount(initializeMinuteMap()); // Now set first values before saving. statistic.setDailyCount(1); statistic.getHourlyCount().put(hourKey, 1); statistic.getMinuteCount().put(minuteKey, 1); statisticsRepository.save(statistic); } else { // Already a statistic document for this day, increment fields. log.debug("Found an existing statistic document for " + day); statisticsRepository.incrementDailyStatistic(day, event.getServiceName(), event.getServiceVersion(), hourKey, minuteKey); } log.debug("Processing of MockInvocationEvent done !"); }
From source file:com.glaf.core.service.impl.WorkCalendarServiceImpl.java
public boolean checkWorkDate(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date);// ww w. ja v a2 s. co m int year = cal.get(Calendar.YEAR); int month = cal.get(Calendar.MONTH); int day = cal.get(Calendar.DAY_OF_MONTH); logger.info("year:" + year + ", month:" + month + ", day:" + day); WorkCalendar bean = find(year, month + 1, day); if (bean != null) { return false; } return true; }
From source file:com.polyvi.xface.extension.XCalendarExt.java
@Override public XExtensionResult exec(String action, JSONArray args, XCallbackContext callbackCtx) throws JSONException { Calendar calendar = Calendar.getInstance(); if (COMMAND_GET_TIME.equals(action)) { // ???//w ww . j av a 2s . c o m int hours = calendar.get(Calendar.HOUR_OF_DAY); int minutes = calendar.get(Calendar.MINUTE); if (2 == args.length()) { hours = args.getInt(0); minutes = args.getInt(1); } getTime(hours, minutes, callbackCtx); } else if (COMMAND_GET_DATE.equals(action)) { // ??? int year = calendar.get(Calendar.YEAR); int month = calendar.get(Calendar.MONTH) + 1; int day = calendar.get(Calendar.DAY_OF_MONTH); if (3 == args.length()) { year = args.getInt(0); month = args.getInt(1); day = args.getInt(2); } getDate(year, month, day, callbackCtx); } XExtensionResult er = new XExtensionResult(XExtensionResult.Status.NO_RESULT); return er; }
From source file:net.sf.l2j.gameserver.model.entity.ClanHallSiege.java
public void setNewSiegeDate(long siegeDate, int ClanHallId, int hour) { Calendar tmpDate = Calendar.getInstance(); if (siegeDate <= System.currentTimeMillis()) { tmpDate.setTimeInMillis(System.currentTimeMillis()); tmpDate.add(Calendar.DAY_OF_MONTH, 3); tmpDate.set(Calendar.DAY_OF_WEEK, 6); tmpDate.set(Calendar.HOUR_OF_DAY, hour); tmpDate.set(Calendar.MINUTE, 0); tmpDate.set(Calendar.SECOND, 0); setSiegeDate(tmpDate);//w w w . j ava 2 s .c o m Connection con = null; try { con = L2DatabaseFactory.getInstance().getConnection(); PreparedStatement statement = con .prepareStatement("UPDATE clanhall_siege SET siege_data=? WHERE id = ?"); statement.setLong(1, getSiegeDate().getTimeInMillis()); statement.setInt(2, ClanHallId); statement.execute(); statement.close(); } catch (Exception e) { _log.error("Exception: can't save clanhall siege date: " + e.getMessage(), e); } finally { try { if (con != null) con.close(); } catch (SQLException e) { e.printStackTrace(); } } } }
From source file:gov.nih.nci.cabig.caaers.domain.DateTimeValue.java
/** * Instantiates a new date value.//ww w . j a va 2 s . c om * * @param date the date */ public DateTimeValue(Date date) { GregorianCalendar gc = new GregorianCalendar(); gc.setTime(date); this.day = gc.get(Calendar.DAY_OF_MONTH); this.month = gc.get(Calendar.MONTH) + 1; this.year = gc.get(Calendar.YEAR); }
From source file:net.ceos.project.poi.annotated.bean.FreeElementAdvancedObjectBuilder.java
/** * Validate the FreeElementAdvancedObject based on the object build with the * method 'buildFreeElementAdvancedObject' * /* ww w .ja va2 s.co m*/ * @param toValidate * the object to validate */ public static void validateFreeElementAdvancedObject(FreeElementAdvancedObject toValidate) { FreeElementAdvancedObject base = buildFreeElementAdvancedObject(); Calendar calendar = Calendar.getInstance(); calendar.setTime(new Date()); Calendar calendarUnmarshal = Calendar.getInstance(); calendarUnmarshal.setTime(toValidate.getFreeDate()); assertEquals(calendar.get(Calendar.YEAR), calendarUnmarshal.get(Calendar.YEAR)); assertEquals(calendar.get(Calendar.MONTH), calendarUnmarshal.get(Calendar.MONTH)); assertEquals(calendar.get(Calendar.DAY_OF_MONTH), calendarUnmarshal.get(Calendar.DAY_OF_MONTH)); assertEquals(base.getFreeString(), toValidate.getFreeString()); assertEquals(base.getFreeDouble(), toValidate.getFreeDouble()); assertEquals(base.getFreePrimitiveInt(), toValidate.getFreePrimitiveInt()); assertEquals(base.getFreeLong(), toValidate.getFreeLong()); assertEquals(base.isFreePrimitiveBoolean(), toValidate.isFreePrimitiveBoolean()); // TODO add new validation below }
From source file:net.ceos.project.poi.annotated.bean.AutoResizeObjectBuilder.java
/** * Validate the AutoResizeObject based on the object build with the method * 'buildAutoResizeObject'// w ww .j av a2 s .c om * * @param toValidate * the object to validate */ public static void validateAutoResizeObject(AutoResizeObject toValidate) { AutoResizeObject base = buildAutoResizeObject(); Calendar calendar = Calendar.getInstance(); calendar.setTime(new Date()); Calendar calendarUnmarshal = Calendar.getInstance(); calendarUnmarshal.setTime(toValidate.getDateAttribute()); assertEquals(calendar.get(Calendar.YEAR), calendarUnmarshal.get(Calendar.YEAR)); assertEquals(calendar.get(Calendar.MONTH), calendarUnmarshal.get(Calendar.MONTH)); assertEquals(calendar.get(Calendar.DAY_OF_MONTH), calendarUnmarshal.get(Calendar.DAY_OF_MONTH)); assertEquals(base.getStringAttribute(), toValidate.getStringAttribute()); assertEquals(base.getDoubleAttribute(), toValidate.getDoubleAttribute()); assertEquals(base.getLongAttribute(), toValidate.getLongAttribute()); assertEquals(base.isBooleanPrimitiveAttribute(), toValidate.isBooleanPrimitiveAttribute()); assertEquals(base.getFloatPrimitiveAttribute(), toValidate.getFloatPrimitiveAttribute()); assertEquals(base.getUnitFamily(), toValidate.getUnitFamily()); assertEquals(base.getBigDecimalAttribute(), toValidate.getBigDecimalAttribute()); // TODO add new validation below }
From source file:net.sourceforge.fenixedu.presentationTier.TagLib.sop.examsMapNew.renderers.ExamsMapContentRenderer.java
@Override public StringBuilder renderDayLabel(ExamsMapSlot examsMapSlot, ExamsMap examsMap, String typeUser, PageContext pageContext) {/* w w w . j a va 2s.c o m*/ this.examsMap = examsMap; StringBuilder strBuffer = new StringBuilder(); boolean isFirstDayOfSeason = ((examsMapSlot.getDay().get(Calendar.DAY_OF_MONTH) == examsMap .getFirstDayOfSeason().get(Calendar.DAY_OF_MONTH)) && (examsMapSlot.getDay().get(Calendar.MONTH) == examsMap.getFirstDayOfSeason().get(Calendar.MONTH)) && (examsMapSlot.getDay().get(Calendar.YEAR) == examsMap.getFirstDayOfSeason().get(Calendar.YEAR))); boolean isSecondDayOfMonthAndFirstDayWasASunday = (examsMapSlot.getDay().get(Calendar.DAY_OF_MONTH) == 2 && examsMapSlot.getDay().get(Calendar.DAY_OF_WEEK) == 2); if (examsMap.getInfoExecutionDegree() != null && typeUser.equals("sop")) { strBuffer.append("<a href='showExamsManagement.do?method=createByDay" + "&" + PresentationConstants.EXECUTION_DEGREE_OID + "=" + examsMap.getInfoExecutionDegree().getExternalId() + "&" + PresentationConstants.EXECUTION_PERIOD_OID + "=" + examsMap.getInfoExecutionPeriod().getExternalId() + "&" + PresentationConstants.CURRICULAR_YEAR_OID + "=" + examsMap.getCurricularYears().iterator().next() + "&" + PresentationConstants.DAY + "=" + examsMapSlot.getDay().get(Calendar.DAY_OF_MONTH) + "&" + PresentationConstants.MONTH + "=" + (examsMapSlot.getDay().get(Calendar.MONTH) + 1) + "&" + PresentationConstants.YEAR + "=" + examsMapSlot.getDay().get(Calendar.YEAR) + "'>"); } strBuffer.append(examsMapSlot.getDay().get(Calendar.DAY_OF_MONTH)); if ((examsMapSlot.getDay().get(Calendar.DAY_OF_MONTH) == 1) || isFirstDayOfSeason || isSecondDayOfMonthAndFirstDayWasASunday) { strBuffer.append(" "); strBuffer.append(getMessageResource(pageContext, "public.degree.information.label.of")); strBuffer.append(" "); Locale locale = pageContext.getRequest().getLocale(); strBuffer.append(monthToString(examsMapSlot.getDay().get(Calendar.MONTH), locale)); } if (examsMapSlot.getDay().get(Calendar.DAY_OF_YEAR) == 1) { strBuffer.append(getMessageResource(pageContext, "public.degree.information.label.comma")); strBuffer.append(examsMapSlot.getDay().get(Calendar.YEAR)); } if (examsMap.getInfoExecutionDegree() != null && typeUser.equals("sop")) { strBuffer.append("</a>"); } strBuffer.append("<br />"); return strBuffer; }