/** @return number of trimester, if weeks value is correct; -1 otherwise */ private int getTrimesterNumber() { if (age != null && age.getWeeks() >= 0) { if (age.getWeeks() <= getFirstTrimesterEndInclusive()) { return FIRST_TRIMESTER; } else if (age.getWeeks() <= getSecondTrimesterEndInclusive()) { return SECOND_TRIMESTER; } else if (getDurationInDays() <= getMaxDurationInDays()) { return THIRD_TRIMESTER; } } return -1; }
public void setCurrentPoint(Calendar current) { currentPoint = (Calendar) current.clone(); zeroDate(currentPoint); long difference = currentPoint.getTimeInMillis() - startPoint.getTimeInMillis(); int days = (int) (difference / (1000L * 3600L * 24L)); int weeks = days / Age.DAYS_IN_WEEK; days = days - weeks * Age.DAYS_IN_WEEK; try { if (age == null) { age = new Age(weeks, days); } else { age.setDays(days); age.setWeeks(weeks); } } catch (Exception e) { age = null; } }
@SuppressWarnings("unused") public int getDays() { return age == null ? -1 : age.getDays(); }
public String getInfo(Context context) { return age == null ? "null" : age.toString(context); }
private int getDurationInDays() { return age == null ? -1 : age.getDurationInDays(); }