Example usage for java.time ZonedDateTime getDayOfMonth

List of usage examples for java.time ZonedDateTime getDayOfMonth

Introduction

In this page you can find the example usage for java.time ZonedDateTime 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) {
    ZonedDateTime dateTime = ZonedDateTime.now();

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

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 birthdateUserAttribute() {
    User user = retrieveUserWithAttributes();
    Attribute attribute = user.getUserAttributes().get("birthdate");
    assertTrue(attribute instanceof DateAttribute);
    assertThat(attribute.getName(), is("birthdate"));
    final Date value = new Date(((Date) attribute.getValue()).getTime());
    ZonedDateTime v = value.toInstant().atZone(ZoneId.systemDefault());
    assertThat(v.getDayOfMonth(), is(5));
    assertThat(v.getMonthValue(), is(7));
    assertThat(v.getYear(), is(1980));/*from w w  w. j  a  v  a2 s  . c o m*/
}

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. ja  v  a  2s.com*/
    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  av  a 2 s .  c  o  m
 *
 * @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.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);/*from  ww  w .j a  v  a  2s  .c om*/

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