Example usage for java.time Month FEBRUARY

List of usage examples for java.time Month FEBRUARY

Introduction

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

Prototype

Month FEBRUARY

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

Click Source Link

Document

The singleton instance for the month of February with 28 days, or 29 in a leap year.

Usage

From source file:Main.java

public static void main(String[] args) {
    // the current date
    LocalDate currentDate = LocalDate.now();
    System.out.println(currentDate);

    // 2014-02-10
    LocalDate tenthFeb2014 = LocalDate.of(2014, Month.FEBRUARY, 10);
    System.out.println(tenthFeb2014); // 2014-02-10

    // months values start at 1 (2014-08-01)
    LocalDate firstAug2014 = LocalDate.of(2014, 8, 1);
    System.out.println(firstAug2014); // 2014-08-01

    // the 65th day of 2010 (2010-03-06)
    LocalDate sixtyFifthDayOf2010 = LocalDate.ofYearDay(2010, 65);
    System.out.println(sixtyFifthDayOf2010); // 2014-03-06
}

From source file:Main.java

public static void main(String[] argv) {
    YearMonth currentYearMonth = YearMonth.now();
    System.out.printf("Days in month year %s: No of days: %s \n", currentYearMonth,
            currentYearMonth.lengthOfMonth());
    YearMonth creditCardExpiry = YearMonth.of(2018, Month.FEBRUARY);
    System.out.printf("Your credit card expires on %s: No of days: %s \n", creditCardExpiry,
            creditCardExpiry.lengthOfMonth());

}

From source file:Main.java

public static void main(String[] args) {

    // the current date
    LocalDate currentDate = LocalDate.now();

    // 2014-02-10
    LocalDate tenthFeb2014 = LocalDate.of(2014, Month.FEBRUARY, 10);

    // months values start at 1 (2014-08-01)
    LocalDate firstAug2014 = LocalDate.of(2014, 8, 1);

    // the 65th day of 2010 (2010-03-06)
    LocalDate sixtyFifthDayOf2010 = LocalDate.ofYearDay(2010, 65);

    // times, e.g. 19:12:30.733

    LocalTime currentTime = LocalTime.now(); // current time
    LocalTime midday = LocalTime.of(12, 0); // 12:00
    LocalTime afterMidday = LocalTime.of(13, 30, 15); // 13:30:15

    // 12345th second of day (03:25:45)
    LocalTime fromSecondsOfDay = LocalTime.ofSecondOfDay(12345);

    // dates with times, e.g. 2014-02-18T19:08:37.950
    LocalDateTime currentDateTime = LocalDateTime.now();

    // 2014-10-02 12:30
    LocalDateTime secondAug2014 = LocalDateTime.of(2014, 10, 2, 12, 30);

    // 2014-12-24 12:00
    LocalDateTime christmas2014 = LocalDateTime.of(2014, Month.DECEMBER, 24, 12, 0);

    // current (local) time in Los Angeles
    LocalTime currentTimeInLosAngeles = LocalTime.now(ZoneId.of("America/Los_Angeles"));

    // current time in UTC time zone
    LocalTime nowInUtc = LocalTime.now(Clock.systemUTC());

    System.out.println("date/time creation: currentDate: " + currentDate);
    System.out.println("date/time creation: tenthFeb2014: " + tenthFeb2014);
    System.out.println("date/time creation: firstAug2014: " + firstAug2014);
    System.out.println("date/time creation: sixtyFifthDayOf2010: " + sixtyFifthDayOf2010);
    System.out.println("date/time creation: currentTime: " + currentTime);
    System.out.println("date/time creation: midday: " + midday);
    System.out.println("date/time creation: afterMidday: " + afterMidday);
    System.out.println("date/time creation: fromSecondsOfDay: " + fromSecondsOfDay);
    System.out.println("date/time creation: currentTimeInLosAngeles: " + currentTimeInLosAngeles);
    System.out.println("date/time creation: currentDateTime: " + currentDateTime);
    System.out.println("date/time creation: secondAug2014: " + secondAug2014);
    System.out.println("date/time creation: christmas2014: " + christmas2014);
}

From source file:Main.java

public static void main(String[] args) {
    Year year_2014 = Year.of(2014);
    System.out.println(year_2014);

    LocalDate year_month_day = Year.of(2014).atMonth(3).atDay(23);
    System.out.println(year_month_day);

    LocalDate year_and_day = Year.of(1974).atDay(77); // 1974-03-18
    System.out.println(year_and_day);

    System.out.println(MonthDay.of(Month.FEBRUARY, 29));

}

From source file:fi.luontola.cqrshotel.JsonSerializationTest.java

private static Object randomValue(Class<?> type) {
    ThreadLocalRandom random = ThreadLocalRandom.current();
    if (type == UUID.class) {
        return UUID.randomUUID();
    }//w  w  w. jav a2 s.c  o  m
    if (type == LocalDate.class) {
        return LocalDate.of(random.nextInt(2000, 2100),
                random.nextInt(Month.JANUARY.getValue(), Month.DECEMBER.getValue() + 1),
                random.nextInt(1, Month.FEBRUARY.minLength() + 1));
    }
    if (type == Money.class) {
        return Money.of(random.nextDouble(0, 1000), pickRandom(Monetary.getCurrencies()));
    }
    if (type == Instant.class) {
        return Instant.ofEpochMilli(random.nextLong());
    }
    if (type == String.class) {
        return RandomStringUtils.randomAlphanumeric(random.nextInt(10));
    }
    if (type == int.class) {
        return random.nextInt();
    }
    throw new IllegalArgumentException("Unsupported type: " + type);
}

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) -> {//  w  ww  .  jav  a 2 s.  c  o 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;
}