Advertisement
romancha

OddDate

Aug 29th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.58 KB | None | 0 0
  1. import java.text.SimpleDateFormat;
  2. import java.util.GregorianCalendar;
  3. import java.util.Locale;
  4.  
  5. public class tesdt {
  6.     public static void main(String[] args) throws Exception{
  7.         System.out.println(isDateOdd("JANUARY 2 2000"));
  8.     }
  9.  
  10.     public static boolean isDateOdd(String date) throws Exception{
  11.         SimpleDateFormat df = new SimpleDateFormat("MMMMM d yyyy", Locale.ENGLISH);
  12.         GregorianCalendar calendar = new GregorianCalendar();
  13.         calendar.setTime(df.parse(date));
  14.         return calendar.get(GregorianCalendar.DAY_OF_YEAR) % 2 == 0;
  15.     }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement