Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.time.LocalDate;
import java.time.Month;
import java.time.format.DateTimeFormatter;
import java.time.temporal.Temporal;
import java.util.Locale;

public class Main {

    public static void main(String[] args) {
        LocalDate ld = LocalDate.of(2014, Month.JUNE, 30);
        format(ld, "M/d/yyyy");
        format(ld, "MM/dd/yyyy");
        format(ld, "MMM   dd,   yyyy");
        format(ld, "MMMM   dd,   yyyy");
        format(ld, "EEEE, MMMM   dd,   yyyy");
        format(ld, "'Month' q  'in' QQQ");
    }

    public static void format(Temporal co, String pattern) {
        DateTimeFormatter fmt = DateTimeFormatter.ofPattern(pattern);
        String str = fmt.format(co);
        System.out.println(pattern + ": " + str);
    }
}