Example usage for org.joda.time DateTime getMinuteOfHour

List of usage examples for org.joda.time DateTime getMinuteOfHour

Introduction

In this page you can find the example usage for org.joda.time DateTime getMinuteOfHour.

Prototype

public int getMinuteOfHour() 

Source Link

Document

Get the minute of hour field value.

Usage

From source file:es.usc.citius.servando.calendula.fragments.ScheduleTimetableFragment.java

License:Open Source License

void setupHourlyRepetitionLinsteners() {
    hourlyIntervalEditText.setOnClickListener(new View.OnClickListener() {
        @Override//from www.j  a  va 2s  . c  o m
        public void onClick(View v) {
            showHourlyPickerDIalog();
        }
    });

    hourlyIntervalFrom.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            DateTime time = schedule.startTime().toDateTimeToday();

            RadialTimePickerDialog timePickerDialog = RadialTimePickerDialog.newInstance(
                    ScheduleTimetableFragment.this, time.getHourOfDay(), time.getMinuteOfHour(), true);
            timePickerDialog.show(getChildFragmentManager(), "111");
        }
    });

    hourlyIntervalRepeatDose.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showHourlyDosePickerDialog();
        }
    });
}

From source file:etc.HelperUtils.java

License:Apache License

/**
 * Takes the Timestamp in milis and parses it to the form "yyyy-MM-dd HH:mm" or to "unlimited", if zero
 * //from w  w  w .ja  v a  2  s  .  c  o  m
 * @param ts_Active
 *            the timestamp
 * @return the parsed timestamp
 */
public static String parseStringTs(long ts_Active) {
    if (ts_Active == 0)
        return "unlimited";

    DateTime dt = new DateTime(ts_Active);
    StringBuilder timeString = new StringBuilder();
    // add a leading "0" if the value is under ten
    timeString.append(dt.getYear()).append("-");
    timeString.append(addZero(dt.getMonthOfYear()));
    timeString.append("-");
    timeString.append(addZero(dt.getDayOfMonth()));
    timeString.append(" ");
    timeString.append(addZero(dt.getHourOfDay()));
    timeString.append(":");
    timeString.append(addZero(dt.getMinuteOfHour()));
    return timeString.toString();

}

From source file:eu.itesla_project.cases.EntsoeCaseRepository.java

License:Mozilla Public License

private <R> R scanRepository(DateTime date, CaseType type, Country country,
        Function<List<ImportContext>, R> handler) {
    Collection<UcteGeographicalCode> geographicalCodes = country != null ? forCountryHacked(country)
            : Collections.singleton(UcteGeographicalCode.UX);
    for (EntsoeFormat format : formats) {
        Path formatDir = config.getRootDir().resolve(format.getDirName());
        if (Files.exists(formatDir)) {
            Path typeDir = formatDir.resolve(type.name());
            if (Files.exists(typeDir)) {
                Path dayDir = typeDir.resolve(String.format("%04d", date.getYear()))
                        .resolve(String.format("%02d", date.getMonthOfYear()))
                        .resolve(String.format("%02d", date.getDayOfMonth()));
                if (Files.exists(dayDir)) {
                    List<ImportContext> importContexts = null;
                    for (UcteGeographicalCode geographicalCode : geographicalCodes) {
                        Collection<String> forbiddenFormats = config.getForbiddenFormatsByGeographicalCode()
                                .get(geographicalCode);
                        if (!forbiddenFormats.contains(format.getImporter().getFormat())) {
                            for (int i = 9; i >= 0; i--) {
                                String baseName = String.format(
                                        "%04d%02d%02d_%02d%02d_" + type + "%01d_" + geographicalCode.name()
                                                + "%01d",
                                        date.getYear(), date.getMonthOfYear(), date.getDayOfMonth(),
                                        date.getHourOfDay(), date.getMinuteOfHour(), date.getDayOfWeek(), i);
                                ReadOnlyDataSource ds = dataSourceFactory.create(dayDir, baseName);
                                if (importContexts == null) {
                                    importContexts = new ArrayList<>();
                                }//from w w w .ja  v  a  2 s. c  om
                                if (format.getImporter().exists(ds)) {
                                    importContexts.add(new ImportContext(format.getImporter(), ds));
                                }
                            }
                        }
                    }
                    if (importContexts != null) {
                        R result = handler.apply(importContexts);
                        if (result != null) {
                            return result;
                        }
                    }
                }
            }
        }
    }
    return null;
}

From source file:eu.itesla_project.entsoe.cases.EntsoeCaseRepository.java

License:Mozilla Public License

private <R> R scanRepository(DateTime date, CaseType type, Country country,
        Function<List<ImportContext>, R> handler) {
    Collection<EntsoeGeographicalCode> geographicalCodes = country != null ? forCountryHacked(country)
            : Collections.singleton(EntsoeGeographicalCode.UX);
    for (EntsoeFormat format : formats) {
        Path formatDir = config.getRootDir().resolve(format.getDirName());
        if (Files.exists(formatDir)) {
            Path typeDir = formatDir.resolve(type.name());
            if (Files.exists(typeDir)) {
                Path dayDir = typeDir.resolve(String.format("%04d", date.getYear()))
                        .resolve(String.format("%02d", date.getMonthOfYear()))
                        .resolve(String.format("%02d", date.getDayOfMonth()));
                if (Files.exists(dayDir)) {
                    List<ImportContext> importContexts = null;
                    for (EntsoeGeographicalCode geographicalCode : geographicalCodes) {
                        Collection<String> forbiddenFormats = config.getForbiddenFormatsByGeographicalCode()
                                .get(geographicalCode);
                        if (!forbiddenFormats.contains(format.getImporter().getFormat())) {
                            for (int i = 9; i >= 0; i--) {
                                String baseName = String.format(
                                        "%04d%02d%02d_%02d%02d_" + type + "%01d_" + geographicalCode.name()
                                                + "%01d",
                                        date.getYear(), date.getMonthOfYear(), date.getDayOfMonth(),
                                        date.getHourOfDay(), date.getMinuteOfHour(), date.getDayOfWeek(), i);
                                ReadOnlyDataSource ds = dataSourceFactory.create(dayDir, baseName);
                                if (importContexts == null) {
                                    importContexts = new ArrayList<>();
                                }/*ww  w.ja v  a 2  s.c  om*/
                                if (format.getImporter().exists(ds)) {
                                    importContexts.add(new ImportContext(format.getImporter(), ds));
                                }
                            }
                        }
                    }
                    if (importContexts != null) {
                        R result = handler.apply(importContexts);
                        if (result != null) {
                            return result;
                        }
                    }
                }
            }
        }
    }
    return null;
}

From source file:eu.uqasar.web.dashboard.widget.datadeviation.DataDeviationWidget.java

License:Apache License

public Options getQualityParameterOptions() {

    Project proj = null;// www  .  j a  v  a 2s  .com
    String projName = "";
    String qualityParameterChoice = "";

    proj = getProject(settings.get("project"));
    if (proj != null) {
        projName = proj.getName();
        System.out.println("projName: " + projName);
    }

    qualityParameterChoice = settings.get("qualityParams");
    //      if (qualityParameterChoice == null || qualityParameterChoice.isEmpty()) {         
    //         qualityParameterChoice = OBJS;
    //      }   

    System.out.println("qualityParameterChoice: " + qualityParameterChoice);

    Options options = new Options();
    ChartOptions chartOptions = new ChartOptions();

    // DATA
    List<HistoricValuesBaseIndicator> historicValues = getHistoricalValues();
    List<HistoricValuesBaseIndicator> qualityParam = new LinkedList<>();

    List<Float> baseIndicatorValues = new LinkedList<>();
    // get and save parameter values
    for (HistoricValuesBaseIndicator hv : historicValues) {
        if (hv.getBaseIndicator().getName().equals(qualityParameterChoice)) {
            qualityParam.add(hv);
            baseIndicatorValues.add(hv.getBaseIndicator().getValue());
        }
    }

    // calculate deviations
    // test: overwrite values
    //      baseIndicatorValues.set(0, 40087.0f);
    //      baseIndicatorValues.set(1, 39457.0f);
    //      baseIndicatorValues.set(2, 41347.0f);
    //      baseIndicatorValues.set(3, 44777.0f);

    System.out.println("baseIndicatorValues: " + baseIndicatorValues);
    List<Float> deviations = calculateDeviations(baseIndicatorValues);
    System.out.println("deviations: " + deviations);

    SeriesType seriesType = SeriesType.SPLINE;
    chartOptions.setType(seriesType);
    chartTitle = new Title("Deviations of " + qualityParameterChoice);
    options.setTitle(chartTitle);
    PointSeries series = new PointSeries();
    series.setType(seriesType);

    List<String> xAxisLabels = new ArrayList<>();

    for (int f = 0; f < deviations.size(); f++) {
        String name = qualityParam.get(f).getBaseIndicator().getName();
        float value = deviations.get(f);
        series.addPoint(new Point(name, value));
        //xAxis Label
        DateTime dateTime = new DateTime(qualityParam.get(f).getDate());
        String dateFormated = String.valueOf(dateTime.getMonthOfYear()) + "/"
                + String.valueOf(dateTime.dayOfMonth().get()) + "/" + String.valueOf(dateTime.getYear()) + " - "
                + String.valueOf(dateTime.getHourOfDay()) + ":" + String.valueOf(dateTime.getMinuteOfHour());
        xAxisLabels.add(dateFormated);

    }

    // Date on xAxis
    Axis xAxis = new Axis();
    xAxis.setType(AxisType.DATETIME);
    xAxis.setCategories(xAxisLabels);
    xAxis.setLabels(new Labels().setRotation(-60).setAlign(HorizontalAlignment.RIGHT).setStyle(
            new CssStyle().setProperty("font-size", "10px").setProperty("font-family", "Verdana, sans-serif")));
    options.setxAxis(xAxis);

    options.addSeries(series);
    options.setChartOptions(chartOptions);

    return options;
}

From source file:eu.uqasar.web.dashboard.widget.uqasardatavisualization.UqasarDataVisualizationWidget.java

License:Apache License

public Options getQualityParameterOptions() {

    Project proj = null;/* w w  w . ja  v a  2  s. c om*/
    String projName = "";
    Map<String, List<TreeNode>> qualityParameters = new HashMap<>();
    String qualityParameterChoice = "";

    proj = getProject(settings.get("project"));
    if (proj != null) {
        projName = proj.getName();
    }

    qualityParameterChoice = settings.get("qualityParams");
    if (qualityParameterChoice == null || qualityParameterChoice.isEmpty()) {
        qualityParameterChoice = ALL.get(0); // all params
    }
    System.out.println("qualityParameterChoice: " + qualityParameterChoice);

    Options options = new Options();
    ChartOptions chartOptions = new ChartOptions();

    if (qualityParameterChoice.equals(ALL.get(0))) {
        // DATA
        qualityParameters = getQualityParametersFromProject(proj);
        SeriesType seriesType = SeriesType.COLUMN;
        // CHART
        chartOptions.setType(seriesType);
        chartTitle = new Title(ALL.get(0) + " of " + projName);
        options.setTitle(chartTitle);
        for (String key : qualityParameters.keySet()) {
            PointSeries series = new PointSeries();
            series.setType(seriesType);
            int siz = qualityParameters.get(key).size();
            series.addPoint(new Point(key, siz));
            series.setName(key);
            options.addSeries(series);
        }
        options.setChartOptions(chartOptions);
    } else {

        // DATA
        List<HistoricValuesBaseIndicator> HistoricValuesBaseIndicator = getHistoricalValues();
        List<HistoricValuesBaseIndicator> data = new LinkedList<>();

        for (HistoricValuesBaseIndicator hv : HistoricValuesBaseIndicator) {
            if (hv.getBaseIndicator().getName().equals(qualityParameterChoice)) {
                data.add(hv);
            }
        }

        SeriesType seriesType = SeriesType.SPLINE;
        chartOptions.setType(seriesType);
        chartTitle = new Title(qualityParameterChoice + " of " + projName);
        options.setTitle(chartTitle);
        PointSeries series = new PointSeries();
        series.setType(seriesType);

        List<String> xAxisLabels = new ArrayList<>();

        for (HistoricValuesBaseIndicator dat : data) {
            String name = dat.getBaseIndicator().getName();
            float value = dat.getBaseIndicator().getValue();
            series.addPoint(new Point(name, value));

            //xAxis Label
            //xAxis Label
            DateTime dateTime = new DateTime(dat.getDate());
            String dateFormated = String.valueOf(dateTime.getMonthOfYear()) + "/"
                    + String.valueOf(dateTime.dayOfMonth().get()) + "/" + String.valueOf(dateTime.getYear())
                    + " - " + String.valueOf(dateTime.getHourOfDay()) + ":"
                    + String.valueOf(dateTime.getMinuteOfHour());
            xAxisLabels.add(dateFormated);

        }

        // Date on xAxis
        Axis xAxis = new Axis();
        xAxis.setType(AxisType.DATETIME);
        xAxis.setCategories(xAxisLabels);
        xAxis.setLabels(
                new Labels().setRotation(-60).setAlign(HorizontalAlignment.RIGHT).setStyle(new CssStyle()
                        .setProperty("font-size", "10px").setProperty("font-family", "Verdana, sans-serif")));
        options.setxAxis(xAxis);

        options.addSeries(series);
        options.setChartOptions(chartOptions);
    }

    return options;
}

From source file:fi.hsl.parkandride.back.TimeUtil.java

License:EUPL

public static DateTime roundMinutes(int resolution, DateTime dateTime) {
    int minute = dateTime.getMinuteOfHour();
    int remainder = minute % resolution;
    int roundedRem = (int) (Math.round(((double) remainder) / resolution) * resolution);
    return dateTime.plusMinutes(roundedRem - remainder).withSecondOfMinute(0).withMillisOfSecond(0);
}

From source file:fr.amap.commons.animation.Timeline.java

public static double getDecimalHour(DateTime time) {
    return getDecimalHour(time.getHourOfDay(), time.getMinuteOfHour(), time.getSecondOfMinute());
}

From source file:gov.usgs.anss.query.filefactory.SacHeaders.java

License:Open Source License

public static SacTimeSeries setEventHeader(SacTimeSeries sac, DateTime eventOrigin, Double eventLat,
        Double eventLon, Double eventDepth, Double eventMag, int sacMagType, int sacEventType) {

    if (eventLat == null) {
        eventLat = -12345.0;//from   w  ww. j  a va 2s  .c o  m
    }

    if (eventLon == null) {
        eventLon = -12345.0;
    }

    if (eventDepth == null) {
        eventDepth = -12345.0;
    }

    if (eventMag == null) {
        eventMag = -12345.0;
    }

    // SAC stores year day (nzjday) but not month and day.  
    DateTime start = new DateTime(sac.nzyear, 1, 1, sac.nzhour, sac.nzmin, sac.nzsec, sac.nzmsec,
            DateTimeZone.UTC);
    start = start.withDayOfYear(sac.nzjday);

    double timeDiff = (start.getMillis() - eventOrigin.getMillis()) / 1000.0d;

    sac.nzyear = eventOrigin.getYear();
    sac.nzjday = eventOrigin.getDayOfYear();
    sac.nzhour = eventOrigin.getHourOfDay();
    sac.nzmin = eventOrigin.getMinuteOfHour();
    sac.nzsec = eventOrigin.getSecondOfMinute();
    sac.nzmsec = eventOrigin.getMillisOfSecond();

    sac.b = sac.b + timeDiff;
    sac.e = sac.e + timeDiff;

    sac.iztype = SacTimeSeries.IO;

    sac.evla = eventLat;
    sac.evlo = eventLon;
    sac.evdp = eventDepth;
    sac.mag = eventMag;
    sac.imagtyp = sacMagType;
    sac.ievtyp = sacEventType;

    sac.lcalda = 1;

    return sac;
}

From source file:influent.server.dataaccess.DataAccessHelper.java

License:MIT License

public static String format(DateTime dateTime) {

    if (dateTime == null) {
        return null;
    }// w  w w . jav a2  s. c om

    StringBuilder s = new StringBuilder(10);

    s.append(dateTime.getYear());
    s.append('-');

    pad00(dateTime.getMonthOfYear(), s);
    s.append('-');

    pad00(dateTime.getDayOfMonth(), s);
    s.append(' ');

    pad00(dateTime.getHourOfDay(), s);
    s.append(':');

    pad00(dateTime.getMinuteOfHour(), s);
    s.append(':');

    pad00(dateTime.getSecondOfMinute(), s);
    s.append('.');

    int ms = dateTime.getMillisOfSecond();

    if (ms < 100) {
        s.append('0');
    }
    pad00(ms, s);

    return s.toString();
}