Example usage for java.util Calendar DAY_OF_MONTH

List of usage examples for java.util Calendar DAY_OF_MONTH

Introduction

In this page you can find the example usage for java.util Calendar DAY_OF_MONTH.

Prototype

int DAY_OF_MONTH

To view the source code for java.util Calendar DAY_OF_MONTH.

Click Source Link

Document

Field number for get and set indicating the day of the month.

Usage

From source file:eu.trentorise.smartcampus.mobility.processor.alerts.ParkingChecker.java

private static String buildDate() {
    Calendar cal = new GregorianCalendar();
    return cal.get(Calendar.DAY_OF_MONTH) + "-" + cal.get(Calendar.MONTH) + "-" + cal.get(Calendar.YEAR);
}

From source file:gaffer.example.gettingstarted.generator.DataGenerator8.java

@Override
public Element getElement(final String line) {
    final String[] t = line.split(",");
    final Edge.Builder edgeBuilder = new Edge.Builder().group("data").source(t[0]).dest(t[1]).directed(true)
            .property("visibility", t[3]).property("count", 1L);

    final Date startDate;
    try {//w  w w .ja v  a2s  .  c  om
        startDate = DateUtils.truncate(new SimpleDateFormat("dd/MM/yyyy HH:mm").parse(t[2]),
                Calendar.DAY_OF_MONTH);
        edgeBuilder.property("startDate", startDate).property("endDate", DateUtils.addDays(startDate, 1));
    } catch (ParseException e) {
        throw new IllegalArgumentException("Unable to parse date", e);
    }

    return edgeBuilder.build();
}

From source file:net.sf.housekeeper.swing.util.BoundComponentFactory.java

/**
 * Creates a JSpinner whose value is bound to the given ValueModel. This
 * means, that the value of the spinner and the value of the ValueModel are
 * synchronized bidirectionally. Additionally, the spinner uses
 * the current locale's short format for displaying a date.
 * /*from   w w w  .  j  a va 2s. co m*/
 * @param valueModel the model that provides the value. Must not be null and
 *            must provide {@link Date}objects.
 * @return A spinner whose value is bound to <code>valueModel</code>.
 */
public static JSpinner createDateSpinner(final ValueModel valueModel) {
    assert valueModel != null : "Parameter valueModel must not be null";
    assert valueModel.getValue().getClass()
            .equals(Date.class) : "valueModel must provide Date objects as values";

    final SpinnerDateModel model = new SpinnerDateModelAdapter(valueModel);
    //Need to truncate the current date for correct spinner operation
    model.setStart(DateUtils.truncate(new Date(), Calendar.DAY_OF_MONTH));
    model.setCalendarField(Calendar.DAY_OF_MONTH);

    final JSpinner spinner = new JSpinner(model);

    //Set the spinner's editor to use the current locale's short date
    // format
    final SimpleDateFormat dateFormat = (SimpleDateFormat) SimpleDateFormat.getDateInstance(DateFormat.SHORT);
    final String formatPattern = dateFormat.toPattern();
    spinner.setEditor(new JSpinner.DateEditor(spinner, formatPattern));

    return spinner;
}

From source file:de.fischer.thotti.reportgen.combiner.AverageDayCombinerIterator.java

@Override
Measurement getNextElementComputed() {/* w ww . ja  va2s .  c  om*/
    Measurement result = new Measurement();
    Date date = DateUtils.truncate(dayOfNextElement, Calendar.DAY_OF_MONTH);
    result.setPointInTime(date);
    result.setDuration(durationAggregatedDay / elementsDay);

    return result;
}

From source file:com.swiftcorp.portal.common.util.CalendarUtils.java

public static Calendar addDayToCurrentDate(int day) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(new Date());
    calendar.add(Calendar.DAY_OF_MONTH, day);

    return calendar;
}

From source file:de.hybris.platform.accountsummaryaddon.document.B2BDocumentDueDateRangePredicate.java

@Override
public boolean evaluate(final Object doc) {
    if (!(doc instanceof B2BDocumentModel)) {
        return false;
    }/*from   ww w . j  a v  a  2 s  . c  o  m*/

    final B2BDocumentModel document = (B2BDocumentModel) doc;

    final Date min = XDate.setToEndOfDay(DateUtils.addDays(new Date(), -dateRange.getMinBoundary().intValue()));

    Date max = null;
    if (dateRange.getMaxBoundary() != null) {
        max = DateUtils.truncate(DateUtils.addDays(new Date(), -dateRange.getMaxBoundary().intValue()),
                Calendar.DAY_OF_MONTH);
    }

    return (dateRange.getMaxBoundary() == null
            || (document.getDueDate() != null && document.getDueDate().getTime() >= max.getTime()))
            && (document.getDueDate() != null && document.getDueDate().getTime() <= min.getTime());
}

From source file:DateUtils.java

public static String getTimestamp() {
    Calendar cal = Calendar.getInstance();
    cal.setTime(new Date());

    int year = cal.get(Calendar.YEAR);
    int month = cal.get(Calendar.MONTH) + 1;
    int day = cal.get(Calendar.DAY_OF_MONTH);
    int hours = cal.get(Calendar.HOUR_OF_DAY);
    // use 24 hour clock
    int minutes = cal.get(Calendar.MINUTE);
    int seconds = cal.get(Calendar.SECOND);
    int milli = cal.get(Calendar.MILLISECOND);

    return "" + year + "-" + month + "-" + day + "_" + formatTime(hours, minutes, seconds, milli);
}

From source file:net.netheos.pcsapi.providers.hubic.SwiftTest.java

@Test
public void testParseTimestamp() {
    // Check we won't break if a header is missing :
    Headers headers = new Headers();
    Date timestamp = Swift.parseTimestamp(headers);
    assertNull(timestamp);// w w  w  . ja v a  2  s  .co m

    headers.addHeader("X-Timestamp", "1383925113.43900"); // 2013-11-08T16:38:33.439+01:00
    timestamp = Swift.parseTimestamp(headers);

    Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
    cal.setTime(timestamp);
    System.out.println(timestamp);
    assertEquals(2013, cal.get(Calendar.YEAR));
    assertEquals(Calendar.NOVEMBER, cal.get(Calendar.MONTH));
    assertEquals(8, cal.get(Calendar.DAY_OF_MONTH));
    assertEquals(15, cal.get(Calendar.HOUR_OF_DAY));
    assertEquals(38, cal.get(Calendar.MINUTE));
    assertEquals(33, cal.get(Calendar.SECOND));
    assertEquals(439, cal.get(Calendar.MILLISECOND));

    checkTimestamp("1383925113.430723", new Date(1383925113430L));
    checkTimestamp("1383925113.43900", new Date(1383925113439L));
    checkTimestamp("1383925113.439", new Date(1383925113439L));
    checkTimestamp("1383925113.43", new Date(1383925113430L));
    checkTimestamp("1383925113.4", new Date(1383925113400L));
    checkTimestamp("1383925113.", new Date(1383925113000L));
    checkTimestamp("1383925113", new Date(1383925113000L));
}

From source file:edu.wisc.my.stats.query.support.UWDataWareHouseInformationProvider.java

public UWDataWareHouseInformationProvider() {
    this.fieldMap.put(Calendar.YEAR, "DD.CALENDAR_YEAR_NUMBER");
    this.fieldMap.put(Calendar.MONTH, "DD.CALENDAR_MONTH_NUMBER");
    this.fieldMap.put(Calendar.DAY_OF_MONTH, "DD.CALENDAR_DAY_NUMBER");
}

From source file:com.nagarro.core.validator.PaymentDetailsDTOValidator.java

@Override
public void validate(final Object target, final Errors errors) {
    final PaymentDetailsWsDTO paymentDetails = (PaymentDetailsWsDTO) target;

    if (StringUtils.isNotBlank(paymentDetails.getStartMonth())
            && StringUtils.isNotBlank(paymentDetails.getStartYear())
            && StringUtils.isNotBlank(paymentDetails.getExpiryMonth())
            && StringUtils.isNotBlank(paymentDetails.getExpiryYear())) {
        final Calendar start = Calendar.getInstance();
        start.set(Calendar.DAY_OF_MONTH, 0);
        start.set(Calendar.MONTH, Integer.parseInt(paymentDetails.getStartMonth()) - 1);
        start.set(Calendar.YEAR, Integer.parseInt(paymentDetails.getStartYear()) - 1);

        final Calendar expiration = Calendar.getInstance();
        expiration.set(Calendar.DAY_OF_MONTH, 0);
        expiration.set(Calendar.MONTH, Integer.parseInt(paymentDetails.getExpiryMonth()) - 1);
        expiration.set(Calendar.YEAR, Integer.parseInt(paymentDetails.getExpiryYear()) - 1);

        if (start.after(expiration)) {
            errors.rejectValue("startMonth", "payment.startDate.invalid");
        }/*from   w  w  w .  jav  a 2 s. c  om*/
    }

    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "accountHolderName", "field.required");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "cardType.code", "field.required");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "cardNumber", "field.required");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "expiryMonth", "field.required");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "expiryYear", "field.required");

    paymentAddressValidator.validate(paymentDetails, errors);
}