I want to compare current date with the given date. Current date format will be (dd-MM-YYYY). I don't want to get the current year. Suppose today's date is 30-08-2016. I want to get only 30-08, I don't want current year 2016. The given date is 15-08 and 31-08. I did not get the current date like this 30-08. How can I get this and how can I compare? Here is my code which I have tried:
Date date1_aug, date2_aug, cur_date;
String cur_date_string, sDay, sMonth;
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-YYYY");
Calendar calendar = Calendar.getInstance();
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH)+1;
int day = calendar.get(Calendar.DATE);
sDay = Integer.toString(day);
sMonth = Integer.toString(month);
cur_date_string = sDay+"-"+sMonth;
try {
cur_date = sdf.parse(cur_date_string);
} catch (java.text.ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
another function:
try{ date1_aug = sdf.parse("15-08"); date2_aug = sdf.parse("31-08"); if(cur_date.equals(date1_aug) || cur_date.after(date1_aug) || cur_date.before(date2_aug)){ textView_Amount_LateFee.setText(Config.fine_aug.get(1)); } }catch(ParseException ex){ ex.printStackTrace(); }