Example usage for java.time ZonedDateTime getMinute

List of usage examples for java.time ZonedDateTime getMinute

Introduction

In this page you can find the example usage for java.time ZonedDateTime getMinute.

Prototype

public int getMinute() 

Source Link

Document

Gets the minute-of-hour field.

Usage

From source file:Main.java

public static void main(String[] args) {
    ZonedDateTime dateTime = ZonedDateTime.now();

    System.out.println(dateTime.getMinute());
}

From source file:onl.area51.httpd.action.Request.java

default Request addHeader(String n, ZonedDateTime zdt) {
    return addHeader(n,
            String.format("%3s, %02d %3s %d %02d:%02d:%02d GMT",
                    zdt.getDayOfWeek().getDisplayName(TextStyle.SHORT, Locale.ENGLISH), zdt.getDayOfMonth(),
                    zdt.getMonth().getDisplayName(TextStyle.SHORT, Locale.ENGLISH), zdt.getYear(),
                    zdt.getHour(), zdt.getMinute(), zdt.getSecond()));
}

From source file:org.caratarse.auth.model.dao.UserAttributesTest.java

@Test
public void lastUserAttribute() {
    User user = retrieveUserWithAttributes();
    Attribute attribute = user.getUserAttributes().get("last");
    assertTrue(attribute instanceof DateTimeAttribute);
    assertThat(attribute.getName(), is("last"));
    final Date value = new Date(((Date) attribute.getValue()).getTime());
    ZonedDateTime v = value.toInstant().atZone(ZoneId.of("UTC"));
    assertThat(v.getDayOfMonth(), is(20));
    assertThat(v.getMonthValue(), is(11));
    assertThat(v.getYear(), is(2015));//from   w  w  w  .jav a  2  s.c  o m
    assertThat(v.getHour(), is(12));
    assertThat(v.getMinute(), is(11));
    assertThat(v.getSecond(), is(10));
    assertThat(v.getNano(), is(999000000));
}

From source file:org.eclipse.hawkbit.repository.test.util.AbstractIntegrationTest.java

/**
 * Gets a valid cron expression describing a schedule with a single
 * maintenance window, starting specified number of minutes after current
 * time./*w  w  w. j a v a 2s  .c om*/
 *
 * @param minutesToAdd
 *            is the number of minutes after the current time
 *
 * @return {@link String} containing a valid cron expression.
 */
protected static String getTestSchedule(final int minutesToAdd) {
    ZonedDateTime currentTime = ZonedDateTime.now();
    currentTime = currentTime.plusMinutes(minutesToAdd);
    return String.format("%d %d %d %d %d ? %d", currentTime.getSecond(), currentTime.getMinute(),
            currentTime.getHour(), currentTime.getDayOfMonth(), currentTime.getMonthValue(),
            currentTime.getYear());
}

From source file:org.openhab.binding.buienradar.internal.BuienradarHandler.java

private void refresh() {
    try {/*  ww  w.  ja  va  2  s.  c  om*/
        @SuppressWarnings("null")
        final List<Prediction> predictions = client.getPredictions(location);
        for (final Prediction prediction : predictions) {
            final BigDecimal intensity = prediction.getIntensity();
            final ZonedDateTime nowPlusThree = ZonedDateTime.now().plusMinutes(3);
            final ZonedDateTime lastFiveMinute = nowPlusThree.withMinute((nowPlusThree.getMinute() / 5) * 5)
                    .withSecond(0).withNano(0);
            final long minutesFromNow = lastFiveMinute.until(prediction.getDateTime(), ChronoUnit.MINUTES);
            final long minuteClass = minutesFromNow;
            logger.debug("Forecast for {} at {} is {}", minutesFromNow, prediction.getDateTime(), intensity);
            if (minuteClass >= 0 && minuteClass <= 115) {
                final String label = String.format(Locale.ENGLISH, "forecast_%d", minuteClass);

                /** @TODO: edejong 2019-04-03 Change to SmartHomeUnits.MILLIMETRE_PER_HOUR for OH 2.5 */
                updateState(label, new QuantityType<Speed>(intensity, MILLIMETRE_PER_HOUR));
            }
        }

        updateStatus(ThingStatus.ONLINE);
    } catch (IOException e) {
        logger.warn("Cannot retrieve predictions", e);
        updateStatus(ThingStatus.ONLINE, ThingStatusDetail.COMMUNICATION_ERROR,
                String.format("Could not reach buienradar: %s", e.getMessage()));
    }
}

From source file:org.primeframework.mvc.parameter.convert.converters.ZonedDateTimeConverterTest.java

@Test
public void fromStrings() {
    GlobalConverter converter = new ZonedDateTimeConverter(new MockConfiguration());
    ZonedDateTime value = (ZonedDateTime) converter.convertFromStrings(ZonedDateTime.class, null, "testExpr",
            ArrayUtils.toArray((String) null));
    assertNull(value);/* ww  w  . j  ava  2 s  .  c o  m*/

    value = (ZonedDateTime) converter.convertFromStrings(Locale.class,
            MapBuilder.asMap("dateTimeFormat", "MM-dd-yyyy hh:mm:ss a Z"), "testExpr",
            ArrayUtils.toArray("07-08-2008 10:13:34 AM -0800"));
    assertEquals(value.getMonthValue(), 7);
    assertEquals(value.getDayOfMonth(), 8);
    assertEquals(value.getYear(), 2008);
    assertEquals(value.getHour(), 10);
    assertEquals(value.getMinute(), 13);
    assertEquals(value.getSecond(), 34);
    assertEquals(value.getZone(), ZoneOffset.ofHours(-8));

    try {
        converter.convertFromStrings(Locale.class, MapBuilder.asMap("dateTimeFormat", "MM-dd-yyyy"), "testExpr",
                ArrayUtils.toArray("07/08/2008"));
        fail("Should have failed");
    } catch (ConversionException e) {
        // Expected
    }
}

From source file:org.tightblog.ui.restapi.WeblogEntryController.java

@GetMapping(value = "/{id}")
public WeblogEntry getWeblogEntry(@PathVariable String id, Principal p, HttpServletResponse response)
        throws ServletException {
    try {//from   w  w  w .  j  a  v  a 2s. c  o  m
        WeblogEntry entry = weblogEntryRepository.findByIdOrNull(id);
        if (entry != null) {
            Weblog weblog = entry.getWeblog();
            if (userManager.checkWeblogRole(p.getName(), weblog, WeblogRole.EDIT_DRAFT)) {
                entry.setCommentsUrl(urlService.getCommentManagementURL(weblog.getId(), entry.getId()));
                entry.setPermalink(urlService.getWeblogEntryURL(entry));
                entry.setPreviewUrl(urlService.getWeblogEntryDraftPreviewURL(entry));

                if (entry.getPubTime() != null) {
                    log.debug("entry pubtime is {}", entry.getPubTime());
                    ZonedDateTime zdt = entry.getPubTime().atZone(entry.getWeblog().getZoneId());
                    entry.setHours(zdt.getHour());
                    entry.setMinutes(zdt.getMinute());
                    entry.setCreator(null);
                    entry.setDateString(pubDateFormat.format(zdt.toLocalDate()));
                }

                response.setStatus(HttpServletResponse.SC_OK);
                return entry;
            } else {
                response.setStatus(HttpServletResponse.SC_FORBIDDEN);
            }
        } else {
            response.setStatus(HttpServletResponse.SC_NOT_FOUND);
        }
    } catch (Exception e) {
        log.error("Error retrieving entry {}", id, e);
        throw new ServletException(e.getMessage());
    }
    return null;
}

From source file:stroom.pipeline.server.writer.PathCreator.java

public static String replaceTimeVars(String path) {
    // Replace some of the path elements with system variables.
    final ZonedDateTime dateTime = ZonedDateTime.now(ZoneOffset.UTC);
    path = replace(path, "year", dateTime.getYear(), 4);
    path = replace(path, "month", dateTime.getMonthValue(), 2);
    path = replace(path, "day", dateTime.getDayOfMonth(), 2);
    path = replace(path, "hour", dateTime.getHour(), 2);
    path = replace(path, "minute", dateTime.getMinute(), 2);
    path = replace(path, "second", dateTime.getSecond(), 2);
    path = replace(path, "millis", dateTime.toInstant().toEpochMilli(), 3);
    path = replace(path, "ms", dateTime.toInstant().toEpochMilli(), 0);

    return path;/*w  ww . j  a v  a  2s  .  c o m*/
}