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:com.watchrabbit.crawler.manager.policy.DefaultCleanupPolicy.java

@Override
public void onError(Address address) {
    BlacklistElement blacklistElement = new BlacklistElement(address.getUrl(), address.getKeyword());
    if (withWarning.containsKey(blacklistElement)) {
        if (withWarning.get(blacklistElement).after(clock.getDate())) {
            withWarning.remove(blacklistElement);
            blacklist.add(blacklistElement);
        } else {/*from w  ww  .j av a2 s .co m*/
            withWarning.remove(blacklistElement);
        }
    } else {
        putOnQueueEnd(address);
        Calendar calendar = clock.getCalendar();
        calendar.add(Calendar.DAY_OF_MONTH, 1);
        withWarning.put(blacklistElement, calendar.getTime());
    }
}

From source file:com.arvato.thoroughly.util.CommonUtils.java

/**
 * Get all dates within three months/*from   w  w w .  j ava  2 s.  co  m*/
 *
 * @param startDate
 * @param nowDate
 *
 * @return Sample Data:
 *         <p>
 *         key:value-->start:2001-01-01 00:00:00 <br>
 *         or <br>
 *         end:2001-01-01 23:59:59 <br>
 */
public static List<Map<String, Date>> findDates(Date startDate, Date nowDate) {
    List<Map<String, Date>> lDate = new ArrayList<Map<String, Date>>();
    SimpleDateFormat ymd = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA);
    SimpleDateFormat ymdmhs = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA);

    Calendar calendar = Calendar.getInstance();
    if (nowDate == null && startDate == null) {

        nowDate = calendar.getTime();
        calendar.add(Calendar.MONTH, -3);
        startDate = calendar.getTime();
    } else if (nowDate != null && startDate == null) {

        calendar.add(Calendar.MONTH, -3);
        startDate = calendar.getTime();

    } else if (nowDate == null && startDate != null) {
        nowDate = calendar.getTime();
    }

    try {
        Map<String, Date> beginItem = new HashMap<String, Date>();
        beginItem.put("start", ymdmhs.parse(ymd.format(startDate) + " 00:00:00"));
        beginItem.put("end", ymdmhs.parse(ymd.format(startDate) + " 23:59:59"));

        lDate.add(beginItem);

        Calendar calBegin = Calendar.getInstance();
        calBegin.setTime(startDate);

        Calendar calEnd = Calendar.getInstance();
        calEnd.setTime(startDate);

        while (ymd.parse(ymd.format(nowDate)).after(calBegin.getTime())) {
            calBegin.add(Calendar.DAY_OF_MONTH, 1);
            Map<String, Date> dateItem = new HashMap<String, Date>();

            dateItem.put("start", ymdmhs.parse(ymd.format(calBegin.getTime()) + " 00:00:00"));
            dateItem.put("end", ymdmhs.parse(ymd.format(calBegin.getTime()) + " 23:59:59"));

            lDate.add(dateItem);
        }
    } catch (ParseException e) {
        LOGGER.error(e.getMessage());
    }
    return lDate;
}

From source file:com.collabnet.ccf.core.utils.DateUtil.java

public static Date convertGMTToTimezoneAbsoluteDate(Date dateValue, String sourceSystemTimezone) {
    Calendar cal = new GregorianCalendar(TimeZone.getTimeZone(GMT_TIME_ZONE_STRING));
    cal.setLenient(false);/*from   ww w .  j a v a 2s.  c  o  m*/
    cal.setTime(dateValue);
    Calendar newCal = new GregorianCalendar(TimeZone.getTimeZone(sourceSystemTimezone));
    newCal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
    newCal.set(Calendar.MILLISECOND, 0);
    Date returnDate = newCal.getTime();
    return returnDate;
}

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

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

From source file:ether.RDFHelper.java

public static Model create(String jsonInput, String date) {
    JSONObject jso = new JSONObject(jsonInput);
    String today = "";
    String yesterday = "";
    String etherSchemaFileName = "ether-schema.ttl";
    Model model = ModelFactory.createDefaultModel();
    model.read(etherSchemaFileName, "TURTLE");

    try {/*from  w  w w.  j a v  a 2  s.c  om*/
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Calendar temp = new GregorianCalendar();
        temp.setTime(sdf.parse(date));
        temp.add(Calendar.DAY_OF_MONTH, -1);
        yesterday = sdf.format(temp.getTime());
        today = date;
    } catch (Exception e) {
        e.printStackTrace();
    }

    String qualityToday = jso.getString("gentoday").trim();
    String qualityYesterday = jso.getString("genyest").trim();

    if (levelMap.containsKey(qualityToday)) {

        Resource todayEstimate = model.createResource();
        Resource rdfType = ResourceFactory
                .createResource("http://med.auth.gr/lomi/ether-schema#AirPollutionQualityEstimate");
        todayEstimate.addProperty(RDF.type, rdfType);

        Property estimateForNetwork = ResourceFactory
                .createProperty("http://med.auth.gr/lomi/ether-schema#estimateForNetwork");
        Resource network = ResourceFactory.createResource(
                "http://med.auth.gr/lomi/ether-schema#ThessalonikiMunicipalAirPollutionMeasurementNetwork");
        todayEstimate.addProperty(estimateForNetwork, network);

        Property measurementDate = ResourceFactory
                .createProperty("http://med.auth.gr/lomi/ether-schema#measurementDate");
        model.add(todayEstimate, measurementDate,
                ResourceFactory.createTypedLiteral(today, XSDDatatype.XSDdate));

        Property qualityEstimateValue = ResourceFactory
                .createProperty("http://med.auth.gr/lomi/ether-schema#qualityEstimateValue");
        Resource value = ResourceFactory
                .createResource("http://med.auth.gr/lomi/ether-schema#" + levelMap.get(qualityToday));
        todayEstimate.addProperty(qualityEstimateValue, value);
    }

    if (levelMap.containsKey(qualityYesterday)) {

        Resource yesterdayEstimate = model.createResource();
        Resource rdfType = ResourceFactory
                .createResource("http://med.auth.gr/lomi/ether-schema#AirPollutionQualityEstimate");
        yesterdayEstimate.addProperty(RDF.type, rdfType);

        Property estimateForNetwork = ResourceFactory
                .createProperty("http://med.auth.gr/lomi/ether-schema#estimateForNetwork");
        Resource network = ResourceFactory.createResource(
                "http://med.auth.gr/lomi/ether-schema#ThessalonikiMunicipalAirPollutionMeasurementNetwork");
        yesterdayEstimate.addProperty(estimateForNetwork, network);

        Property measurementDate = ResourceFactory
                .createProperty("http://med.auth.gr/lomi/ether-schema#measurementDate");
        model.add(yesterdayEstimate, measurementDate,
                ResourceFactory.createTypedLiteral(yesterday, XSDDatatype.XSDdate));

        Property qualityEstimateValue = ResourceFactory
                .createProperty("http://med.auth.gr/lomi/ether-schema#qualityEstimateValue");
        Resource value = ResourceFactory
                .createResource("http://med.auth.gr/lomi/ether-schema#" + levelMap.get(qualityYesterday));
        yesterdayEstimate.addProperty(qualityEstimateValue, value);
    }

    for (String keyP : pollutantDailyMap.keySet()) {
        for (String keyS : stationMap.keySet()) {
            String jsonKey = keyP + "_" + keyS;
            try {
                Double value = jso.getDouble(jsonKey);
                Resource dailyMeasurement = model.createResource();

                Resource rdfType = ResourceFactory
                        .createResource("http://med.auth.gr/lomi/ether-schema#AverageDailyMeasurement");
                dailyMeasurement.addProperty(RDF.type, rdfType);

                Property measurementDate = ResourceFactory
                        .createProperty("http://med.auth.gr/lomi/ether-schema#measurementDate");
                model.add(dailyMeasurement, measurementDate,
                        ResourceFactory.createTypedLiteral(yesterday, XSDDatatype.XSDdate));

                Property measurementFromStation = ResourceFactory
                        .createProperty("http://med.auth.gr/lomi/ether-schema#measurementFromStation");
                Resource station = ResourceFactory
                        .createResource("http://med.auth.gr/lomi/ether-schema#" + stationMap.get(keyS));
                dailyMeasurement.addProperty(measurementFromStation, station);

                Property measurementOfPollutant = ResourceFactory
                        .createProperty("http://med.auth.gr/lomi/ether-schema#measurementOfPollutant");
                Resource pollutant = ResourceFactory
                        .createResource("http://med.auth.gr/lomi/ether-schema#" + pollutantDailyMap.get(keyP));
                dailyMeasurement.addProperty(measurementOfPollutant, pollutant);

                Property measurementValue = ResourceFactory
                        .createProperty("http://med.auth.gr/lomi/ether-schema#measurementValue");
                model.add(dailyMeasurement, measurementValue,
                        ResourceFactory.createTypedLiteral(value.toString(), XSDDatatype.XSDfloat));

                Property quantity = ResourceFactory.createProperty("http://qudt.org/schema/qudt#quantity");
                Resource density = ResourceFactory.createResource("http://qudt.org/vocab/quantity#Density");
                model.add(dailyMeasurement, quantity, density);

                Property unit = ResourceFactory.createProperty("http://qudt.org/schema/qudt#unit");
                Resource micro = ResourceFactory
                        .createResource("http://med.auth.gr/lomi/ether-schema#MicrogramPerCubicMeter");
                Resource milli = ResourceFactory
                        .createResource("http://med.auth.gr/lomi/ether-schema#MilligramPerCubicMeter");
                if (keyP.equals("co")) {
                    model.add(dailyMeasurement, unit, milli);
                } else {
                    model.add(dailyMeasurement, unit, micro);
                }
            } catch (Exception e) {
                //nothing
            }
        }
    }
    for (String keyP : pollutantHourlyMap.keySet()) {
        for (String keyS : stationMap.keySet()) {
            String jsonKey = keyP + "_" + keyS;
            try {
                Double value = jso.getDouble(jsonKey);
                Resource hourlyMeasurement = model.createResource();

                Resource rdfType = ResourceFactory
                        .createResource("http://med.auth.gr/lomi/ether-schema#MaximumHourlyMeasurement");
                hourlyMeasurement.addProperty(RDF.type, rdfType);

                Property measurementDate = ResourceFactory
                        .createProperty("http://med.auth.gr/lomi/ether-schema#measurementDate");
                model.add(hourlyMeasurement, measurementDate,
                        ResourceFactory.createTypedLiteral(today, XSDDatatype.XSDdate));

                Property measurementFromStation = ResourceFactory
                        .createProperty("http://med.auth.gr/lomi/ether-schema#measurementFromStation");
                Resource station = ResourceFactory
                        .createResource("http://med.auth.gr/lomi/ether-schema#" + stationMap.get(keyS));
                hourlyMeasurement.addProperty(measurementFromStation, station);

                Property measurementOfPollutant = ResourceFactory
                        .createProperty("http://med.auth.gr/lomi/ether-schema#measurementOfPollutant");
                Resource pollutant = ResourceFactory
                        .createResource("http://med.auth.gr/lomi/ether-schema#" + pollutantHourlyMap.get(keyP));
                hourlyMeasurement.addProperty(measurementOfPollutant, pollutant);

                Property measurementValue = ResourceFactory
                        .createProperty("http://med.auth.gr/lomi/ether-schema#measurementValue");
                model.add(hourlyMeasurement, measurementValue,
                        ResourceFactory.createTypedLiteral(value.toString(), XSDDatatype.XSDfloat));

                Property quantity = ResourceFactory.createProperty("http://qudt.org/schema/qudt#quantity");
                Resource density = ResourceFactory.createResource("http://qudt.org/vocab/quantity#Density");
                model.add(hourlyMeasurement, quantity, density);

                Property unit = ResourceFactory.createProperty("http://qudt.org/schema/qudt#unit");
                Resource micro = ResourceFactory
                        .createResource("http://med.auth.gr/lomi/ether-schema#MicrogramPerCubicMeter");
                Resource milli = ResourceFactory
                        .createResource("http://med.auth.gr/lomi/ether-schema#MilligramPerCubicMeter");
                if (keyP.equals("co")) {
                    model.add(hourlyMeasurement, unit, milli);
                } else {
                    model.add(hourlyMeasurement, unit, micro);
                }
            } catch (Exception e) {
                //nothing
            }
        }
    }

    return model;
}

From source file:org.yamj.core.service.tasks.RecheckTask.java

@Override
public void execute(String options) throws Exception {
    LOG.debug("Execute recheck task");

    int recheck = this.configService.getIntProperty("yamj3.recheck.movie.maxDays", 45);
    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.DAY_OF_MONTH, (0 - recheck));
    this.metadataStorageService.recheckMovie(cal.getTime());

    recheck = this.configService.getIntProperty("yamj3.recheck.tvshow.maxDays", 45);
    cal = Calendar.getInstance();
    cal.add(Calendar.DAY_OF_MONTH, (0 - recheck));
    this.metadataStorageService.recheckTvShow(cal.getTime());

    recheck = this.configService.getIntProperty("yamj3.recheck.person.maxDays", 90);
    cal = Calendar.getInstance();
    cal.add(Calendar.DAY_OF_MONTH, (0 - recheck));
    this.metadataStorageService.recheckPerson(cal.getTime());
}

From source file:com.ekom.ekomerp.global.DateTimeUtils.java

public static Date getLastDayOfMonth(Date date) {
    Calendar calendar = getCalendarWithoutTime(date);
    calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
    return calendar.getTime();
}

From source file:com.github.jjYBdx4IL.utils.parser.BerlinAirQualityParserTest.java

@Test
public void testParseValueBerlin1Txt() throws IOException, ParseException {
    @SuppressWarnings("deprecation")
    String source = IOUtils.toString(getClass().getResourceAsStream("berlin1.txt"));
    AirQualityParseResult result = parser.setSourceDoc(source).parse().getResult(ID_PM10_VERKEHR);
    assertEquals(24, Integer.parseInt(result.getValue()));

    // 01.07.2014 - 11:00 Uhr MESZ
    assertEquals(2014, result.getTime().get(Calendar.YEAR));
    assertEquals(6, result.getTime().get(Calendar.MONTH));
    assertEquals(1, result.getTime().get(Calendar.DAY_OF_MONTH));
    assertEquals(11, result.getTime().get(Calendar.HOUR));
    assertEquals(0, result.getTime().get(Calendar.MINUTE));

    assertTrue(result.getDesc().contains("Verkehrsmessstelle"));

    assertEquals("PM10", result.getType().toString());
}

From source file:net.ceos.project.poi.annotated.bean.FreeElementObjectBuilder.java

/**
 * Validate the FreeElementObject based on the object build with the method
 * 'buildFreeElementObject'//from   w  w  w .  ja v  a2  s  . c  o m
 * 
 * @param toValidate
 *            the object to validate
 */
public static void validateFreeElementObject(FreeElementObject toValidate) {
    FreeElementObject base = buildFreeElementObject();

    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:com.marc.lastweek.web.components.recommendedclassifiedads.RecommendedClassifiedAdsListPanel.java

private void initializeFilterDate() {
    DateTime now = new DateTime(Calendar.getInstance());
    this.date = DateUtils.truncate(now.minusWeeks(1).toCalendar(getLocale()), Calendar.DAY_OF_MONTH);
}