I have string of date with format like this: 19930508. I want to use only 0508 from this string which is MMdd and than compare it with today's MMdd. The code i am using is:
Date todaysDate = new Date();
String dateTest = "19930508";
SimpleDateFormat df = new SimpleDateFormat("MMdd");
Date date = df.parse(dateTest);
String birthDate = df.format(date);
if(birthDate.equals(df.format(todaysDate))){do something}
The problem is the that birthdate formate is not working correctly neither todaysDate. Date date var print nothing and birthDate string print 0220 which makes no sense to me. Anyone with anyidea how can i work with this kind of formating and compare it with todaysdate ?