コード例 #1
0
ファイル: MSSParser.java プロジェクト: IDCH/nttext-commentary
  /**
   * Helper method to set the start date while parsing a date.
   *
   * @param firstDate The string based representation of a date (number only).
   * @param date The <tt>HistoricalDate</tt> object to be updated.
   */
  private void setStartDate(String firstDate, HistoricalDate date) {
    // create a date instance
    try {
      SimpleDateFormat formatter = new SimpleDateFormat("yyyy");
      if (firstDate.length() < 3) {
        firstDate = firstDate + "00";
      } else if (date.getPrecision() == null) {
        date.setPrecision(Precision.YEAR);
      }

      Date d = formatter.parse(firstDate);
      date.setStartDate(d);
    } catch (ParseException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }