コード例 #1
0
 /**
  * 返回最后一条weight的时间
  *
  * @return 返回时间
  */
 public Date getLastWeightDate() {
   if (currentBabyInfo == null) {
     NullPointerException e = new NullPointerException("本地没有缓存weight");
     throw e;
   }
   Date date = null;
   try {
     date = Standar.DATE_FORMAT.parse(currentBabyInfo.getAge());
   } catch (ParseException e) {
     e.printStackTrace();
     return null;
   }
   return date;
 }
コード例 #2
0
  /**
   * 在原来的基础上增加一个weight,主要实现本地monthtoweights的跟新。
   *
   * @param babyInfo 增加的weight信息
   */
  private void addOneWeight(BabyInfo babyInfo) {
    String birth = babyInfo.getAge();
    Date date = null;
    try {
      date = Standar.DATE_FORMAT.parse(birth);
    } catch (ParseException e) {
      e.printStackTrace();
      return;
    }
    int month = Calculator.getBabyMonthAge(date);
    int days = Calculator.getBabyDayAge(date);
    Map<Integer, Float> map = new HashMap<>();
    map.put(days, babyInfo.getWeight());

    Map<Integer, Float> list = monthToweights.get(month);
    if (list == null) {
      list = new HashMap<>();
      monthToweights.put(month, list);
    }
    list.put(days, babyInfo.getWeight());
  }