Пример #1
0
  /** @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;
  }
Пример #2
0
 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;
   }
 }
Пример #3
0
 @SuppressWarnings("unused")
 public int getDays() {
   return age == null ? -1 : age.getDays();
 }
Пример #4
0
 public String getInfo(Context context) {
   return age == null ? "null" : age.toString(context);
 }
Пример #5
0
 private int getDurationInDays() {
   return age == null ? -1 : age.getDurationInDays();
 }