Example usage for java.time LocalDateTime getMonthValue

List of usage examples for java.time LocalDateTime getMonthValue

Introduction

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

Prototype

public int getMonthValue() 

Source Link

Document

Gets the month-of-year field from 1 to 12.

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.getMonthValue());
}

From source file:reactivity.SseController.java

/**
 * <p>/*from w w  w  .j ava2 s.co  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: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   www .  j  a v a2 s.  c  o 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. ja va  2s.  c  o  m

            dataset.addSeries(s1);
        }
    }

    dataset.setDomainIsPointsInTime(true);

    return dataset;
}

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 va2  s  .  c  o  m*/
    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 .c o  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:msi.gama.util.GamaDate.java

public IList<?> listValue(final IScope scope, final IType<?> ct) {
    final LocalDateTime ld = LocalDateTime.from(internal);
    return GamaListFactory.create(scope, ct, ld.getYear(), ld.getMonthValue(), ld.getDayOfWeek().getValue(),
            ld.getHour(), ld.getMinute(), ld.getSecond());
}

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 .  j a  v  a 2  s.  c o m*/

        dataset.addSeries(s1);
    }

    dataset.setDomainIsPointsInTime(true);

    return dataset;
}