Why code:

Date birthday; try { birthday = new SimpleDateFormat("dd.MM.yyyy").parse("01.04.2010"); } catch (Exception ex) { birthday = new Date(1990, 02, 05); } Toast.makeText(context, "DEBUG: " + new DateTime(birthday).getDayOfMonth() + " " + new DateTime(birthday).getMonthOfYear(), Toast.LENGTH_SHORT).show(); 

gives out "DEBUG: 31 3" instead of the logical "DEBUG: 1 4"?

  • Time still in debag place. Does it look like your time zone? - Sergey

1 answer 1

It looks like this line "01/04/2010" does not contain time, so it defaults to 00: 00: 00.000, and iodine takes into account the time zone in the system and subtracts it, so the date goes back. In general, coiled on yet:

 birthday = new SimpleDateFormat("dd.MM.yyyy hh:mm:ss").parse(cursor.getString(birthdayColumnIndex) + " 23:59:00");