Given a date as a string input in the format dd-mm-yy, write a program to extract the month and to print the month name in upper case.
The month names are {JANUARY, FEBRUARY, MARCH, APRIL, MAY, JUNE, JULY, AUGUST, SEPTEMBER, OCTOBER, NOVEMBER, DECEMBER}
Input and Output Format:
Input consists of a String.
The output consists of a String.
Sample Input:
01-06-82
Sample Output:
JUNE
Find month name from a date in Java.
import java.text.ParseException; import java.text.SimpleDateFormat; import java.text.ParseException; import java.util.Date; import java.util.Scanner; public class Main { public static void main(String[] args) throws ParseException { Scanner sc = new Scanner(System.in); String s1 = sc.nextLine(); System.out.println(calculateBornDay(s1)); } public static String calculateBornDay(String s1) throws ParseException { SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yy"); SimpleDateFormat sdf1 = new SimpleDateFormat("MMMM"); Date d = sdf.parse(s1); String s = sdf1.format(d); return s.toUpperCase(); } }