Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.Calendar;
import java.util.GregorianCalendar;

public class Main {
    public static String getReadableDate(int year, int month, int day) {
        Calendar theCalendar = new GregorianCalendar(year, month, day);
        String monthString = getMonthNames(month);
        String result = day + " " + monthString + " " + year;
        return result;
    }

    public static String getMonthNames(int monthNumber) {
        switch (monthNumber) {
        case 1:
            return "January";
        case 2:
            return "February";
        case 3:
            return "March";
        case 4:
            return "April";
        case 5:
            return "May";
        case 6:
            return "June";
        case 7:
            return "July";
        case 8:
            return "August";
        case 9:
            return "September";
        case 10:
            return "October";
        case 11:
            return "November";
        case 12:
            return "December";
        }
        return null;
    }
}