Write a java program to find the day of birth

Given an input as the date of birth of the person, write a program to calculate on which day (MONDAY, TUESDAY….) he was born to store and print the day in Upper Case letters.

The return type of the output is a string which should be the day in which the person was born.

Input and Output Format:

NOTE: date format should be(dd-MM-yyyy)
Input consists a date string.

The output is a string which the day in which the person was born.

Refer sample output for formatting specifications.

Sample Input 1:


Sample Output 1:


Sample Input 2:


Sample Output 2:


Find the day of birth in Java.

import java.text.ParseException;
import java.text.SimpleDateFormat;
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();

  public static String calculateBornDay(String s1) throws ParseException {
    SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
    SimpleDateFormat sdf1 = new SimpleDateFormat("EEEEE");
    Date d = sdf.parse(s1);
    String s = sdf1.format(d);
    return s.toUpperCase();

You May Also Like These Posts:

Leave a Reply

Your email address will not be published.

12 + 18 =