/** * @see CommonDT#setYearMonthDayPrecision(int, int, int) * @throws DataTypeException if the value is incorrectly formatted. If validation is enabled, this * exception should be thrown at setValue(), but if not, detailed parsing may be deferred until * this method is called. */ public void setYearMonthDayPrecision(int yr, int mnth, int dy) throws DataTypeException { getDetail().setYearMonthDayPrecision(yr,mnth,dy); }
/** * @see CommonDT#setYearMonthDayPrecision(int, int, int) * @throws DataTypeException if the value is incorrectly formatted. If validation is enabled, this * exception should be thrown at setValue(), but if not, detailed parsing may be deferred until * this method is called. */ public void setYearMonthDayPrecision(int yr, int mnth, int dy) throws DataTypeException { getDetail().setYearMonthDayPrecision(yr,mnth,dy); }
/** * Convenience setter which sets the value using a {@link Calendar} object. Passing in <code>null</code> clears any existing value. * * Note: Sets fields using maximum possible precision * * @param theCalendar The calendar object from which to retrieve values * @since 1.1 */ public void setValue(Calendar theCalendar) throws DataTypeException { if (theCalendar == null) { setValue((String)null); return; } int yr = theCalendar.get(Calendar.YEAR); int mnth = theCalendar.get(Calendar.MONTH) + 1; int dy = theCalendar.get(Calendar.DATE); setYearMonthDayPrecision(yr, mnth, dy); }
/** * Convenience setter which sets the value using a {@link Calendar} object. Passing in <code>null</code> clears any existing value. * * Note: Sets fields using maximum possible precision * * @param theCalendar The calendar object from which to retrieve values * @since 1.1 */ public void setValue(Calendar theCalendar) throws DataTypeException { if (theCalendar == null) { setValue((String)null); return; } int yr = theCalendar.get(Calendar.YEAR); int mnth = theCalendar.get(Calendar.MONTH) + 1; int dy = theCalendar.get(Calendar.DATE); setYearMonthDayPrecision(yr, mnth, dy); }
/** * This method takes in integer values for the year and month and day * and performs validations, it then sets the value in the object * formatted as an HL7 Time Stamp value with year&month&day precision (YYYYMMDD). * */ public void setDatePrecision(int yr, int mnth, int dy) throws DataTypeException { try { //create date object if there isn't one if (dt == null) { dt = new CommonDT(); } //set the value of the date object to the input date value dt.setYearMonthDayPrecision(yr, mnth, dy); //clear the time value object tm = null; } //end try catch (DataTypeException e) { throw e; } //end catch catch (Exception e) { throw new DataTypeException(e); } //end catch } //end method
/** * This method takes in integer values for the year and month and day * and performs validations, it then sets the value in the object * formatted as an HL7 Time Stamp value with year&month&day precision (YYYYMMDD). * */ public void setDatePrecision(int yr, int mnth, int dy) throws DataTypeException { try { //create date object if there isn't one if (dt == null) { dt = new CommonDT(); } //set the value of the date object to the input date value dt.setYearMonthDayPrecision(yr, mnth, dy); //clear the time value object tm = null; } //end try catch (DataTypeException e) { throw e; } //end catch catch (Exception e) { throw new DataTypeException(e); } //end catch } //end method
/** * Returns a string value representing the input Gregorian Calendar object in * an Hl7 Date Format. */ public static String toHl7DTFormat(GregorianCalendar cal) throws DataTypeException { String val = ""; try { //set the input cal object so that it can report errors //on it's value cal.setLenient(false); int calYear = cal.get(GregorianCalendar.YEAR); int calMonth = cal.get(GregorianCalendar.MONTH) + 1; int calDay = cal.get(GregorianCalendar.DAY_OF_MONTH); CommonDT dt = new CommonDT(); dt.setYearMonthDayPrecision(calYear, calMonth, calDay); val = dt.getValue(); } //end try catch (DataTypeException e) { throw e; } //end catch catch (Exception e) { throw new DataTypeException( e ); } //end catch return val; } //end method
/** * Returns a string value representing the input Gregorian Calendar object in * an Hl7 Date Format. */ public static String toHl7DTFormat(GregorianCalendar cal) throws DataTypeException { String val = ""; try { //set the input cal object so that it can report errors //on it's value cal.setLenient(false); int calYear = cal.get(GregorianCalendar.YEAR); int calMonth = cal.get(GregorianCalendar.MONTH) + 1; int calDay = cal.get(GregorianCalendar.DAY_OF_MONTH); CommonDT dt = new CommonDT(); dt.setYearMonthDayPrecision(calYear, calMonth, calDay); val = dt.getValue(); } //end try catch (DataTypeException e) { throw e; } //end catch catch (Exception e) { throw new DataTypeException( e ); } //end catch return val; } //end method