Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.time.LocalDate;
import java.util.Calendar;
import java.util.Date;

public class Main {
    public static void main(String[] argv) {
        System.out.println(getMonthName(new Date()));
    }

    public static String getMonthName(Date date) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        LocalDate localDate = LocalDate.of(0, cal.get(Calendar.MONTH) + 1, 1);
        return localDate.getMonth().name();
    }
}