Exemplo n.º 1
0
  public int findMinutes() {

    String[] result = time.split(COLON);

    int hrs = new Integer(result[0]);
    int min = new Integer(result[1]);

    boolean am_pm = false;
    if (meridiem.equalsIgnoreCase(MERIDIEM.AM.toString())) am_pm = true;

    int mins = 0;
    if (hrs == 12) mins = 0 + min + (am_pm ? 0 : 12 * 60);
    else mins = (hrs * 60) + min + (am_pm ? 0 : 12 * 60);

    return mins;
  }
Exemplo n.º 2
0
  private void parseTimeTo12HrFmt(Timestamp day) {
    Calendar cl = new GregorianCalendar();
    cl.setTime(day);

    if (cl.get(Calendar.AM_PM) == 0) this.meridiem = MERIDIEM.AM.name();
    else this.meridiem = MERIDIEM.PM.name();

    int hr = cl.get(Calendar.HOUR_OF_DAY);

    hr = (hr == 0 ? 12 : hr);
    hr = (hr > 12 ? hr - 12 : hr);

    int min = cl.get(Calendar.MINUTE);

    String str = buildDisplayView(hr, min);

    this.time = str;
  }