I am new in java programming and i am working for android apps development. I know the basics of java and i can understand the code. I need to know how can I calculate the upcoming birthday total days from my current date.
` btCalculate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String sDate = btBirth.getText().toString();
String eDate = btToday.getText().toString();
SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("dd/MM/yyyy");
try {
Date date1 = simpleDateFormat1.parse(sDate);
Date date2 = simpleDateFormat1.parse(eDate);
long startDate = date1.getTime();
long endDate = date2.getTime();
if (startDate <= endDate) {
Period period = new Period(startDate, endDate, PeriodType.yearMonthDay());
int years = period.getYears();
int months = period.getMonths();
int days = period.getDays();
textView2.setText("আপনার বয়স হচ্ছে : ");
textViewResult.setText(years + " বছর " + months + " মাস " + days + " দিন।");
}
else {
Toast.makeText(getApplicationContext(), "জন্মতারিখ আজকের তারিখের চেয়ে বড় হবে না। ", Toast.LENGTH_SHORT).show();
}
} catch (ParseException e) {
e.printStackTrace();
}
}
});`
i make this and this can calculate total age. I need help to calculate upcoming birthdays. hope you guys help me . thanks