Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.format.TextStyle;
import java.util.Locale;

public class Main {

    public static void main(String[] args) {
        LocalDate date = LocalDate.of(2014, 2, 15); // 2014-02-15
        // ISO-8601 standard
        // the day-of-week to represent, from 1 (Monday) to 7 (Sunday)
        DayOfWeek dayOfWeek = date.getDayOfWeek();
        System.out.println(dayOfWeek); // SATURDAY

        System.out.println(DayOfWeek.of(3)); // WEDNESDAY

        System.out.println(dayOfWeek.getValue()); // 6
        System.out.println(dayOfWeek.name()); // SATURDAY

        System.out.println(date.getDayOfMonth()); // 15
        System.out.println(date.atStartOfDay()); // 2014-02-15 00:00

        System.out.println("DayOfWeek");
        dayOfWeek = DayOfWeek.FRIDAY;
        Locale locale = Locale.getDefault();
        System.out.println(dayOfWeek.getDisplayName(TextStyle.FULL, locale)); // Friday
        System.out.println(dayOfWeek.getDisplayName(TextStyle.NARROW, locale)); // F
        System.out.println(dayOfWeek.getDisplayName(TextStyle.SHORT, locale)); // Fri
    }
}