Example usage for java.time Month APRIL

List of usage examples for java.time Month APRIL

Introduction

In this page you can find the example usage for java.time Month APRIL.

Prototype

Month APRIL

To view the source code for java.time Month APRIL.

Click Source Link

Document

The singleton instance for the month of April with 30 days.

Usage

From source file:Main.java

public static void main(String[] args) {
    // 2014-04-01 10:45
    LocalDateTime dateTime = LocalDateTime.of(2014, Month.APRIL, 1, 10, 45);

    // using a custom pattern (01/04/2014)
    String asCustomPattern = dateTime.format(DateTimeFormatter.ofPattern("dd/MM/yyyy"));

    System.out.println(asCustomPattern);
}

From source file:Main.java

public static void main(String[] args) {
    // 2014-04-01 10:45
    LocalDateTime dateTime = LocalDateTime.of(2014, Month.APRIL, 1, 10, 45);

    // french date formatting (1. avril 2014)
    String frenchDate = dateTime.format(DateTimeFormatter.ofPattern("d. MMMM yyyy", new Locale("fr")));

    System.out.println(frenchDate);
}

From source file:Main.java

public static void main(String[] args) {
    // 2014-04-01 10:45
    LocalDateTime dateTime = LocalDateTime.of(2014, Month.APRIL, 1, 10, 45);

    // using short german date/time formatting (01.04.14 10:45)
    DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT)
            .withLocale(new Locale("de"));
    String germanDateTime = dateTime.format(formatter);

    System.out.println(germanDateTime);
}

From source file:Main.java

public static Boolean isFamilyBirthday(TemporalAccessor date) {
    int month = date.get(ChronoField.MONTH_OF_YEAR);
    int day = date.get(ChronoField.DAY_OF_MONTH);

    // Angie's birthday is on April 3.
    if ((month == Month.APRIL.getValue()) && (day == 3))
        return Boolean.TRUE;

    // Sue's birthday is on June 18.
    if ((month == Month.JUNE.getValue()) && (day == 18))
        return Boolean.TRUE;

    // Joe's birthday is on May 29.
    if ((month == Month.MAY.getValue()) && (day == 29))
        return Boolean.TRUE;

    return Boolean.FALSE;
}

From source file:Main.java

@Override
public Quarter queryFrom(TemporalAccessor temporal) {
    LocalDate now = LocalDate.from(temporal);

    if (now.isBefore(now.with(Month.APRIL).withDayOfMonth(1))) {
        return Quarter.FIRST;
    } else if (now.isBefore(now.with(Month.JULY).withDayOfMonth(1))) {
        return Quarter.SECOND;
    } else if (now.isBefore(now.with(Month.NOVEMBER).withDayOfMonth(1))) {
        return Quarter.THIRD;
    } else {//from ww w.  j  av a 2 s. c o m
        return Quarter.FOURTH;
    }
}

From source file:eu.off.db.entity.MemberTest.java

@Test
public void BuildMinimalMember() {

    LocalDateTime dateTime = LocalDateTime.of(1978, Month.APRIL, 4, 0, 0);
    Date birthday = Date.from(dateTime.atZone(ZoneId.systemDefault()).toInstant());

    Member aMember = new MemberBuilder(LAST_NAME, FIRST_NAME, STREET, ZIP_CODE, PLACE, COUNTRY, birthday,
            GENDER, NATIONALITY).build();

    assertThat(aMember.getLastName().equals(LAST_NAME));
    assertThat(aMember.getFirstName().equals(FIRST_NAME));
    assertThat(aMember.getAdress().equals(STREET));
    assertThat(aMember.getZipCode().equals(ZIP_CODE));
    assertThat(aMember.getPlace().equals(PLACE));
    assertThat(aMember.getCountry().equals(COUNTRY));
    assertThat(aMember.getBirthday().equals(birthday));
    assertThat(aMember.getGender().equals(GENDER));
    assertThat(aMember.getNationality().equals(NATIONALITY));
}

From source file:com.ewerk.prototype.api.PersonControllerIntegTest.java

@BeforeMethod
public void setup() {
    personRepository.deleteAll();/*from w ww.j  a  v a 2 s .co m*/

    Person john = new Person();
    john.setLastName("Smith");
    john.setFirstName("John");
    john.setBirthday(LocalDate.of(2000, Month.DECEMBER, 10));
    personRepository.save(john);

    Person peggy = new Person();
    peggy.setLastName("Mullen");
    peggy.setFirstName("Peggy");
    peggy.setBirthday(LocalDate.of(1957, Month.APRIL, 16));
    personRepository.save(peggy);
}

From source file:eu.off.db.entity.MemberTest.java

@Test
public void BuildFullMember() {

    LocalDateTime dateTime = LocalDateTime.of(1978, Month.APRIL, 4, 0, 0);
    Date birthday = Date.from(dateTime.atZone(ZoneId.systemDefault()).toInstant());

    Member aMember = new MemberBuilder(LAST_NAME, FIRST_NAME, STREET, ZIP_CODE, PLACE, COUNTRY, birthday,
            GENDER, NATIONALITY).email(EMAIL).phone(PHONE).portablePhone(PORTABLE_PHONE).memberSince(birthday)
                    .licenseSince(birthday).build();

    assertThat(aMember.getEmail().equals(EMAIL));
    assertThat(aMember.getPhone().equals(PHONE));
    assertThat(aMember.getPortablePhone().equals(PORTABLE_PHONE));
    assertThat(aMember.getMemberSince().equals(birthday));
    assertThat(aMember.getLicenseSince().equals(birthday));

}

From source file:Main.java

public Boolean queryFrom(TemporalAccessor date) {
    int month = date.get(ChronoField.MONTH_OF_YEAR);
    int day = date.get(ChronoField.DAY_OF_MONTH);

    // Disneyland over Spring Break
    if ((month == Month.APRIL.getValue()) && ((day >= 3) && (day <= 8)))
        return Boolean.TRUE;

    // Smith family reunion on Lake Saugatuck
    if ((month == Month.AUGUST.getValue()) && ((day >= 8) && (day <= 14)))
        return Boolean.TRUE;

    return Boolean.FALSE;
}

From source file:se.backede.jeconomix.forms.report.SingleTransactionReport.java

private DefaultCategoryDataset createDataset(TransactionReportDto reports) {

    String lineTitle = "Kronor";

    Map<Month, BigDecimal> sums = new HashMap<>();

    List<Month> monthList = new LinkedList<>(Arrays.asList(Month.values()));

    monthList.forEach((month) -> {// ww  w.  j  av  a2  s .  co  m
        sums.put(month, BigDecimal.valueOf(0));
    });

    reports.getTransctions().forEach((TransactionDto transaction) -> {
        monthList.stream().filter((month) -> (transaction.getBudgetMonth().equals(month)))
                .forEachOrdered((month) -> {
                    BigDecimal currentSum = sums.get(month);
                    if (transaction.getSum() != null) {
                        double abs = Math.abs(transaction.getSum().doubleValue());
                        BigDecimal newSum = currentSum.add(BigDecimal.valueOf(abs));
                        sums.put(month, newSum);
                    }
                });
    });

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    dataset.addValue(sums.get(Month.JANUARY), lineTitle, "Jan");
    dataset.addValue(sums.get(Month.FEBRUARY), lineTitle, "Feb");
    dataset.addValue(sums.get(Month.MARCH), lineTitle, "Mar");
    dataset.addValue(sums.get(Month.APRIL), lineTitle, "Apr");
    dataset.addValue(sums.get(Month.MAY), lineTitle, "May");
    dataset.addValue(sums.get(Month.JUNE), lineTitle, "Jun");
    dataset.addValue(sums.get(Month.JULY), lineTitle, "Jul");
    dataset.addValue(sums.get(Month.AUGUST), lineTitle, "Aug");
    dataset.addValue(sums.get(Month.SEPTEMBER), lineTitle, "Sep");
    dataset.addValue(sums.get(Month.OCTOBER), lineTitle, "Oct");
    dataset.addValue(sums.get(Month.NOVEMBER), lineTitle, "Nov");
    dataset.addValue(sums.get(Month.DECEMBER), lineTitle, "Dec");
    return dataset;
}