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.clican.pluto.dataprocess.dpl.function.impl.AddDate.java
public void setParams(List<Object> params) throws DplParseException { super.setParams(params); this.date = this.pasList.get(0); String addField = this.pasList.get(1).getConstantsValue(); if (addField.endsWith("day")) { field = Calendar.DAY_OF_MONTH; add = Integer.parseInt(addField.replaceAll("day", "")); } else if (addField.endsWith("month")) { field = Calendar.MONTH;//from w w w. ja v a 2s. c o m add = Integer.parseInt(addField.replaceAll("month", "")); } else if (addField.endsWith("year")) { field = Calendar.YEAR; add = Integer.parseInt(addField.replaceAll("year", "")); } else { throw new PrefixAndSuffixException("??"); } }
From source file:de.hybris.platform.acceleratorservices.web.payment.validation.SopPaymentDetailsValidator.java
@Override public void validate(final Object object, final Errors errors) { final SopPaymentDetailsForm form = (SopPaymentDetailsForm) object; final Calendar startOfCurrentMonth = getCalendarResetTime(); startOfCurrentMonth.set(Calendar.DAY_OF_MONTH, 1); final Calendar startOfNextMonth = getCalendarResetTime(); startOfNextMonth.set(Calendar.DAY_OF_MONTH, 1); startOfNextMonth.add(Calendar.MONTH, 1); final Calendar start = parseDate(form.getCard_startMonth(), form.getCard_startYear()); final Calendar expiration = parseDate(form.getCard_expirationMonth(), form.getCard_expirationYear()); if (start != null && !start.before(startOfNextMonth)) { errors.rejectValue("card_startMonth", "payment.startDate.invalid"); }//from www. jav a 2 s .co m if (expiration != null && expiration.before(startOfCurrentMonth)) { errors.rejectValue("card_expirationMonth", "payment.startDate.invalid"); } if (start != null && expiration != null && start.after(expiration)) { errors.rejectValue("card_startMonth", "payment.startDate.invalid"); } if (StringUtils.isBlank(form.getBillTo_country())) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billTo_country", "address.country.invalid"); } else { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billTo_firstName", "address.firstName.invalid"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billTo_lastName", "address.lastName.invalid"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billTo_street1", "address.line1.invalid"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billTo_city", "address.city.invalid"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billTo_postalCode", "address.postcode.invalid"); } }
From source file:com.adobe.acs.commons.http.headers.impl.DailyExpiresHeaderFilterTest.java
@Test public void testAdjustExpiresPast() throws Exception { Calendar actual = Calendar.getInstance(); actual.set(Calendar.SECOND, 0); actual.set(Calendar.MILLISECOND, 0); Calendar expected = Calendar.getInstance(); expected.setTime(actual.getTime());/*w w w. ja va2 s.c o m*/ expected.add(Calendar.DAY_OF_MONTH, 1); filter.adjustExpires(actual); assertTrue(DateUtils.isSameInstant(expected, actual)); }
From source file:com.epam.cme.storefront.forms.validation.PaymentDetailsValidator.java
@Override public void validate(final Object object, final Errors errors) { final PaymentDetailsForm form = (PaymentDetailsForm) object; if (StringUtils.isNotBlank(form.getStartMonth()) && StringUtils.isNotBlank(form.getStartYear()) && StringUtils.isNotBlank(form.getExpiryMonth()) && StringUtils.isNotBlank(form.getExpiryYear())) { final Calendar start = Calendar.getInstance(); start.set(Calendar.DAY_OF_MONTH, 0); start.set(Calendar.MONTH, Integer.parseInt(form.getStartMonth()) - 1); start.set(Calendar.YEAR, Integer.parseInt(form.getStartYear()) - 1); final Calendar expiration = Calendar.getInstance(); expiration.set(Calendar.DAY_OF_MONTH, 0); expiration.set(Calendar.MONTH, Integer.parseInt(form.getExpiryMonth()) - 1); expiration.set(Calendar.YEAR, Integer.parseInt(form.getExpiryYear()) - 1); if (start.after(expiration)) { errors.rejectValue("startMonth", "payment.startDate.invalid"); }// w ww .j a va 2 s . c o m } final boolean editMode = StringUtils.isNotBlank(form.getPaymentId()); if (editMode || Boolean.TRUE.equals(form.getNewBillingAddress())) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.titleCode", "address.title.invalid"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.firstName", "address.firstName.invalid"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.lastName", "address.lastName.invalid"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.line1", "address.line1.invalid"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.townCity", "address.townCity.invalid"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.postcode", "address.postcode.invalid"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.countryIso", "address.country.invalid"); // ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.line2", // "address.line2.invalid"); // for some addresses this field is required by cybersource } }
From source file:Main.java
/** * Adds a number of days to a date returning a new object. * The original date object is unchanged. * * @param date the date, not null/*w w w. j a va 2s. com*/ * @param amount the amount to add, may be negative * @return the new date object with the amount added * @throws IllegalArgumentException if the date is null */ public static Date addDays(Date date, int amount) { return add(date, Calendar.DAY_OF_MONTH, amount); }
From source file:Main.java
/** * Sets the day of month field to a date returning a new object. * The original date object is unchanged. * * @param date the date, not null/*from w w w. j ava2s.c o m*/ * @param amount the amount to set * @return a new Date object set with the specified value * @throws IllegalArgumentException if the date is null * @since 2.4 */ public static Date setDays(Date date, int amount) { return set(date, Calendar.DAY_OF_MONTH, amount); }
From source file:com.webbfontaine.valuewebb.model.validators.tt.TTDateValidator.java
@Override public boolean isValid(Object value) { int range = Utils.getAppCountry().equals(Constants.GH) ? -3 : -2; if (Utils.currentPage().contains("TtGenList")) { return true; }/*from w w w . j a va 2 s. co m*/ boolean notFuture; if (value != null && value instanceof Date) { Date dateValue = (Date) value; Calendar cal = Calendar.getInstance(); cal.add(Calendar.YEAR, range); notFuture = !DateUtils.truncate(dateValue, Calendar.DAY_OF_MONTH) .after(DateUtils.truncate(new Date(), Calendar.DAY_OF_MONTH)); // value must not be in future return notFuture && dateValue.after(cal.getTime()); } return true; }
From source file:model.listini.Period.java
public Boolean checkDates() { Boolean startDateBeforeEndDate = DateUtils.truncatedCompareTo(this.getEndDate(), this.getStartDate(), Calendar.DAY_OF_MONTH) >= 0; Boolean equalYears = this.getStartYear().equals(this.getEndYear()); Boolean ret = true;//from w ww .ja va2 s. com if (!startDateBeforeEndDate || !equalYears) { ret = false; } return ret; }
From source file:com.aw.core.format.FechaEnTextoFormatter.java
public Object format(Object attributeValue) { Date date = (Date) attributeValue; Calendar cal = new GregorianCalendar(); cal.setTime(date);// w w w.j av a 2 s .c om int anio = cal.get(Calendar.YEAR); int mes = cal.get(Calendar.MONTH); int dia = cal.get(Calendar.DAY_OF_MONTH); Map meses = buildMesesMap(); String valor = dia + " de " + meses.get(mes) + " del " + anio; return valor; }
From source file:com.collabnet.ccf.core.utils.DateUtil.java
public static Date convertDateToTimeZone(Date date, String toTimeZone) { Calendar toCal = new GregorianCalendar(TimeZone.getTimeZone(toTimeZone)); Calendar fromCal = new GregorianCalendar(); fromCal.setTime(date);/*from ww w .ja v a2 s. com*/ toCal.set(fromCal.get(Calendar.YEAR), fromCal.get(Calendar.MONTH), fromCal.get(Calendar.DAY_OF_MONTH), fromCal.get(Calendar.HOUR_OF_DAY), fromCal.get(Calendar.MINUTE), fromCal.get(Calendar.SECOND)); toCal.set(Calendar.MILLISECOND, fromCal.get(Calendar.MILLISECOND)); return toCal.getTime(); }