Example usage for java.time LocalDateTime getDayOfMonth

List of usage examples for java.time LocalDateTime getDayOfMonth

Introduction

In this page you can find the example usage for java.time LocalDateTime getDayOfMonth.

Prototype

public int getDayOfMonth() 

Source Link

Document

Gets the day-of-month field.

Usage

From source file:Main.java

public static void main(String[] args) {
    LocalDateTime a = LocalDateTime.of(2014, 6, 30, 12, 01);

    System.out.println(a.getDayOfMonth());
}

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

/**
 * Validate the MultiTypeObject based on the object build with the method
 * 'buildMultiTypeObject'/*  ww  w. j a  va2 s . co m*/
 * 
 * @param toValidate
 *            the object to validate
 */
public static void validateMultiTypeObject(MultiTypeObject toValidate) {
    MultiTypeObject base = buildMultiTypeObject();

    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));
    LocalDate localDate = LocalDate.now();
    assertEquals(localDate.getDayOfMonth(), toValidate.getLocalDateAttribute().getDayOfMonth());
    assertEquals(localDate.getMonth(), toValidate.getLocalDateAttribute().getMonth());
    assertEquals(localDate.getYear(), toValidate.getLocalDateAttribute().getYear());
    LocalDateTime localDateTime = LocalDateTime.now();
    assertEquals(localDateTime.getDayOfMonth(), toValidate.getLocalDateTimeAttribute().getDayOfMonth());
    assertEquals(localDateTime.getMonth(), toValidate.getLocalDateTimeAttribute().getMonth());
    assertEquals(localDateTime.getYear(), toValidate.getLocalDateTimeAttribute().getYear());
    assertEquals(localDateTime.getHour(), toValidate.getLocalDateTimeAttribute().getHour());

    /* it is possible to have an error below due the time of execution of the test */
    assertEquals(localDateTime.getMinute(), toValidate.getLocalDateTimeAttribute().getMinute());

    assertEquals(base.getStringAttribute(), toValidate.getStringAttribute());
    assertEquals(base.getIntegerAttribute(), toValidate.getIntegerAttribute());
    assertEquals(base.getDoubleAttribute(), toValidate.getDoubleAttribute());
    assertEquals(base.getLongAttribute(), toValidate.getLongAttribute());
    assertEquals(base.getBooleanAttribute(), toValidate.getBooleanAttribute());
    assertEquals(base.getJob().getJobCode(), toValidate.getJob().getJobCode());
    assertEquals(base.getJob().getJobFamily(), toValidate.getJob().getJobFamily());
    assertEquals(base.getJob().getJobName(), toValidate.getJob().getJobName());
    assertEquals(base.getIntegerPrimitiveAttribute(), toValidate.getIntegerPrimitiveAttribute());
    assertEquals(base.getDoublePrimitiveAttribute(), toValidate.getDoublePrimitiveAttribute());
    assertEquals(base.getLongPrimitiveAttribute(), toValidate.getLongPrimitiveAttribute());
    assertEquals(base.isBooleanPrimitiveAttribute(), toValidate.isBooleanPrimitiveAttribute());
    assertEquals(base.getAddressInfo().getAddress(), toValidate.getAddressInfo().getAddress());
    assertEquals(base.getAddressInfo().getNumber(), toValidate.getAddressInfo().getNumber());
    assertEquals(base.getAddressInfo().getCity(), toValidate.getAddressInfo().getCity());
    assertEquals(base.getAddressInfo().getCityCode(), toValidate.getAddressInfo().getCityCode());
    assertEquals(base.getAddressInfo().getCountry(), toValidate.getAddressInfo().getCountry());
    assertEquals(base.getFloatAttribute(), toValidate.getFloatAttribute());
    assertEquals(base.getFloatPrimitiveAttribute(), toValidate.getFloatPrimitiveAttribute());
    assertEquals(base.getUnitFamily(), toValidate.getUnitFamily());
    assertEquals(base.getBigDecimalAttribute(), toValidate.getBigDecimalAttribute());
    assertEquals(base.getShortAttribute(), toValidate.getShortAttribute());
    assertEquals(base.getShortPrimitiveAttribute(), toValidate.getShortPrimitiveAttribute());
    // TODO add new validation below
}

From source file:edu.unibonn.plotting.TimeSeriesPlotter_Sensors.java

private XYDataset createDataset(ArrayList<Sensor> sensors) {
    final TimeSeriesCollection dataset = new TimeSeriesCollection();

    for (int i = 0; i < sensors.size(); i++) {
        Sensor current_sensor = sensors.get(i);

        final TimeSeries s1 = new TimeSeries("Sensor " + i, Hour.class);

        for (int j = 0; j < current_sensor.getDimensions(); j++) {
            LocalDateTime current_record_time = current_sensor.getInitial_record_time().plusHours(j);
            s1.add(new Hour(current_record_time.getHour(), current_record_time.getDayOfMonth(),
                    current_record_time.getMonthValue(), current_record_time.getYear()),
                    current_sensor.getMeasurement(j));
        }//from ww w .  jav  a  2s. co  m

        dataset.addSeries(s1);
    }

    dataset.setDomainIsPointsInTime(true);

    return dataset;
}

From source file:edu.unibonn.plotting.TimeSeriesPlotter_Sensors.java

private XYDataset createDataset(ArrayList<Cluster_KMeans> clusters, LocalDateTime from) {
    final TimeSeriesCollection dataset = new TimeSeriesCollection();

    for (int i = 0; i < clusters.size(); i++) {
        Cluster_KMeans current_cluster = clusters.get(i);
        ArrayList<Sensor> member_time_series = current_cluster.getMembership();

        for (Iterator iterator = member_time_series.iterator(); iterator.hasNext();) {
            final TimeSeries s1 = new TimeSeries("Cluster_" + current_cluster.getCluster_id(), Hour.class);

            Sensor current_series = (Sensor) iterator.next();

            for (int j = 0; j < current_series.getDimensions(); j++) {
                LocalDateTime current_record_time = current_series.getInitial_record_time().plusHours(j);
                s1.add(new Hour(current_record_time.getHour(), current_record_time.getDayOfMonth(),
                        current_record_time.getMonthValue(), current_record_time.getYear()),
                        current_series.getMeasurement(j));
            }/*from  w w w .j  a v a  2  s . com*/

            dataset.addSeries(s1);
        }
    }

    dataset.setDomainIsPointsInTime(true);

    return dataset;
}

From source file:reactivity.SseController.java

/**
 * <p>/*from   w ww. j  av a2 s.c o  m*/
 * Retrieves and pushes the timeseries associated to the given artifact.
 * </p>
 *
 * @param a the artifact associated to timeseries
 */
private void timeseries(final Artifact a) {

    // Compute the key
    final LocalDateTime i = LocalDateTime.ofInstant(Instant.ofEpochMilli(a.getTimestamp()),
            ZoneId.systemDefault());
    final Object[] key = new Object[] { a.getGroup().getType() + "/" + a.getGroup().getName(), i.getYear(),
            i.getMonthValue(), i.getDayOfMonth() };

    repository.color(key).subscribe((item) -> replayProcessor.onNext(sse(Artifact.class.cast(item))));
}

From source file:net.atomique.ksar.graph.Graph.java

private Second convertLocalDateTimeToSecond(LocalDateTime ldt) {

    int day = ldt.getDayOfMonth();
    int month = ldt.getMonthValue();
    int year = ldt.getYear();
    int hour = ldt.getHour();
    int minute = ldt.getMinute();
    int second = ldt.getSecond();

    return new Second(second, minute, hour, day, month, year);
}

From source file:net.atomique.ksar.graph.Graph.java

public int parse_line(LocalDateTime ldt, String s) {

    Second now = new Second(ldt.getSecond(), ldt.getMinute(), ldt.getHour(), ldt.getDayOfMonth(),
            ldt.getMonthValue(), ldt.getYear());

    parse_line(now, s);//  w w  w. j  a  v a  2 s  . com
    return 0;
}

From source file:edu.unibonn.kmeans.mapreduce.plotting.TimeSeriesPlotter_KMeans.java

private XYDataset createDataset(ArrayList<Sensor> sensors) {
    final TimeSeriesCollection dataset = new TimeSeriesCollection();

    for (int i = 0; i < sensors.size(); i++)
    //for (int i = 0; i < 100; i++)
    {//from   w w  w.j a  v a  2 s  .  co  m
        Sensor current_sensor = sensors.get(i);
        ArrayList<Measurement> current_measurements = current_sensor.getMeasurements();

        final TimeSeries s1 = new TimeSeries("Sensor " + i, Hour.class);

        for (int j = 0; j < current_measurements.size(); j++) {
            Measurement current_measurement = current_measurements.get(j);

            LocalDateTime current_time = current_measurement.getRecord_time();

            s1.add(new Hour(current_time.getHour(), current_time.getDayOfMonth(), current_time.getMonthValue(),
                    current_time.getYear()), current_measurement.getErlang());
        }

        dataset.addSeries(s1);
    }

    dataset.setDomainIsPointsInTime(true);

    return dataset;
}

From source file:dk.dma.ais.packet.AisPacketCSVOutputSink.java

protected String formatEta(Date eta) {
    LocalDateTime time = LocalDateTime.ofInstant(Instant.ofEpochMilli(eta.getTime()), ZoneId.systemDefault());
    return formatEta(time.getDayOfMonth(), time.getMonthValue(), time.getHour(), time.getMinute());
}

From source file:edu.unibonn.kmeans.mapreduce.plotting.TimeSeriesPlotter_KMeans.java

private XYDataset createDataset_centroids(ArrayList<Cluster_KMeans> clusters, LocalDateTime from) {
    final TimeSeriesCollection dataset = new TimeSeriesCollection();

    for (int i = 0; i < clusters.size(); i++) {
        Cluster_KMeans current_cluster = clusters.get(i);
        double[] center_of_mass = current_cluster.getCenter_of_mass();

        final TimeSeries s1 = new TimeSeries("Cluster_" + current_cluster.getCluster_id(), Hour.class);

        for (int j = 0; j < 24; j++) {
            s1.add(new Hour(j, from.getDayOfMonth(), from.getMonthValue(), from.getYear()), center_of_mass[j]);
        }// w  w w .  jav  a  2s .c o  m

        dataset.addSeries(s1);
    }

    dataset.setDomainIsPointsInTime(true);

    return dataset;
}