/** * @see CommonTM#setHourMinSecondPrecision(int, int, float) * @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 setHourMinSecondPrecision(int hr, int min, float sec) throws DataTypeException { getDetail().setHourMinSecondPrecision(hr,min,sec); }
/** * @see CommonTM#setHourMinSecondPrecision(int, int, float) * @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 setHourMinSecondPrecision(int hr, int min, float sec) throws DataTypeException { getDetail().setHourMinSecondPrecision(hr,min,sec); }
/** * Convenience setter which sets the value using a {@link Calendar} object. Passing in <code>null</code> clears any existing value. * * Note: Sets fields using precision up to the second * * @param theCalendar The calendar object from which to retrieve values * @since 1.1 */ public void setValueToSecond(Calendar theCalendar) throws DataTypeException { if (theCalendar == null) { setValue((String)null); return; } int hr = theCalendar.get(Calendar.HOUR_OF_DAY); int min = theCalendar.get(Calendar.MINUTE); int sec = theCalendar.get(Calendar.SECOND); setHourMinSecondPrecision(hr, min, sec); }
/** * Convenience setter which sets the value using a {@link Calendar} object. Passing in <code>null</code> clears any existing value. * * Note: Sets fields using precision up to the second * * @param theCalendar The calendar object from which to retrieve values * @since 1.1 */ public void setValueToSecond(Calendar theCalendar) throws DataTypeException { if (theCalendar == null) { setValue((String)null); return; } int hr = theCalendar.get(Calendar.HOUR_OF_DAY); int min = theCalendar.get(Calendar.MINUTE); int sec = theCalendar.get(Calendar.SECOND); setHourMinSecondPrecision(hr, min, sec); }
/** * Convenience setter which sets the value using a {@link Calendar} object. Passing in <code>null</code> clears any existing value. * * Note: Sets fields using precision up to the millisecond, including timezone offset * * @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 hr = theCalendar.get(Calendar.HOUR_OF_DAY); int min = theCalendar.get(Calendar.MINUTE); float sec = theCalendar.get(Calendar.SECOND) + (theCalendar.get(Calendar.MILLISECOND) / 1000.0F); setHourMinSecondPrecision(hr, min, sec); // 3410095: care for integer overflow and timezones not at the full hour, e.g. India int hourOffset= theCalendar.get(Calendar.ZONE_OFFSET) / (1000 * 60 * 60); int minuteOffset = (theCalendar.get(Calendar.ZONE_OFFSET) / (1000 * 60)) % 60; int zoneOffset = hourOffset * 100 + minuteOffset; setOffset(zoneOffset); }
/** * Convenience setter which sets the value using a {@link Calendar} object. Passing in <code>null</code> clears any existing value. * * Note: Sets fields using precision up to the millisecond, including timezone offset * * @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 hr = theCalendar.get(Calendar.HOUR_OF_DAY); int min = theCalendar.get(Calendar.MINUTE); float sec = theCalendar.get(Calendar.SECOND) + (theCalendar.get(Calendar.MILLISECOND) / 1000.0F); setHourMinSecondPrecision(hr, min, sec); // 3410095: care for integer overflow and timezones not at the full hour, e.g. India int hourOffset= theCalendar.get(Calendar.ZONE_OFFSET) / (1000 * 60 * 60); int minuteOffset = (theCalendar.get(Calendar.ZONE_OFFSET) / (1000 * 60)) % 60; int zoneOffset = hourOffset * 100 + minuteOffset; setOffset(zoneOffset); }
tm.setHourMinSecondPrecision(calHour, calMin, calSecFloat); tm.setOffset(calOffset); val = tm.getValue();
tm.setHourMinSecondPrecision(calHour, calMin, calSecFloat); tm.setOffset(calOffset); val = tm.getValue();
/** * This method takes in integer values for the year, month, day, hour, minute, seconds, * and fractional seconds (going to the tenthousandths precision). * The method performs validations and then sets the value in the object formatted as an * HL7 time value with a precision that starts from the year and goes down to the tenthousandths * of a second (YYYYMMDDHHMMSS.SSSS). * The Gmt Offset will not be effected. * Note: all of the precisions from tenths down to * tenthousandths of a second are optional. If the precision goes below tenthousandths * of a second then the second value will be rounded to the nearest tenthousandths of a second. */ public void setDateSecondPrecision(int yr, int mnth, int dy, int hr, int min, float sec) throws DataTypeException { try { //set the value of the date object to the input date value this.setDatePrecision(yr, mnth, dy); //create new time object is there isn't one if (tm == null) { tm = new CommonTM(); } //set the value of the time object to the second precision with the input values tm.setHourMinSecondPrecision(hr, min, sec); } //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, month, day, hour, minute, seconds, * and fractional seconds (going to the tenthousandths precision). * The method performs validations and then sets the value in the object formatted as an * HL7 time value with a precision that starts from the year and goes down to the tenthousandths * of a second (YYYYMMDDHHMMSS.SSSS). * The Gmt Offset will not be effected. * Note: all of the precisions from tenths down to * tenthousandths of a second are optional. If the precision goes below tenthousandths * of a second then the second value will be rounded to the nearest tenthousandths of a second. */ public void setDateSecondPrecision(int yr, int mnth, int dy, int hr, int min, float sec) throws DataTypeException { try { //set the value of the date object to the input date value this.setDatePrecision(yr, mnth, dy); //create new time object is there isn't one if (tm == null) { tm = new CommonTM(); } //set the value of the time object to the second precision with the input values tm.setHourMinSecondPrecision(hr, min, sec); } //end try catch (DataTypeException e) { throw e; } //end catch catch (Exception e) { throw new DataTypeException(e); } //end catch } //end method