Write a program to read a string containing the date in DD/MM/YYYY format and check if its a leap year. If so, return true else return false.
The return type is the boolean indicating TRUE / FALSE.
Input and Output Format:
Input consists of a string.
The output consists of TRUE / FALSE.
Refer sample output for formatting specifications.
Sample Input 1:
23/02/2012
Sample Output 1:
TRUE
Sample Input 2:
12/12/2011
Sample Output 2:
FALSE
Write a java program to validate date format in DD/MM/YYYY
import java.io.IOException; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; public class Main { public static void main(String[] args) throws IOException, ParseException { String s1="23/02/2012"; SimpleDateFormat sdf=new SimpleDateFormat("dd/MM/yyyy"); GregorianCalendar g=new GregorianCalendar(); StringTokenizer t=new StringTokenizer(s1,"/"); String s2=t.nextToken(); String s3=t.nextToken(); String s4=t.nextToken(); int n1=Integer.parseInt(s4); Date d1=sdf.parse(s1); boolean b=g.isLeapYear(n1); System.out.println(b); } }