0
, когда я пытаюсь вычислить дни рождения для всегда дает мне неправильное число днейAndroid Datepicker расчета дней до дня рождения
Можете ли вы помочь мне, что случилось?
Calendar call1 = Calendar.getInstance();
Calendar call2 = Calendar.getInstance();
int day2 = call2.get(Calendar.DAY_OF_MONTH);
int month2 = call2.get(Calendar.MONTH);
int year2 = call2.get(Calendar.YEAR);
if (month2 > month ) {
}
else if (month == month2){
if(year2 < day){
}
}call1.set(day2, month , day);
long millis = call2.getTimeInMillis()
- call1.getTimeInMillis();
long days = millis/86400000L;
Toast.makeText(this.getApplicationContext(), "The number of days until your birthday"
+ days, Toast.LENGTH_SHORT).show();
text2.setText(""+ days);
text2.setTextColor(Color.parseColor("#990000"));
Это первая часть кода:
SharedPreferences dp2 = this.getSharedPreferences("dp", 0);
int day = dp2.getInt("day", 0);
int month = dp2.getInt("month", 0) + 1;
int year = dp2.getInt("year", 0);
text1.setText(day + "/" + month + "/" + year);
https://github.com/dlew/joda-time-android. Используйте время Джоды. Дата между диапазоном http://stackoverflow.com/questions/3802893/number-of-days-between-two-dates-in-joda-time – Raghunandan