/** * Format the dateObject (of type date, time, or timestamp) into a string * optionally using the DatabaseTimeZone. * @param dateObject * @return Formatted string */ public String formatDateValue(java.util.Date dateObject, boolean useTimezone) { if (dateObject instanceof Timestamp && getTimestampNanoPrecision() < 9) { Timestamp ts = (Timestamp)dateObject; Timestamp newTs = new Timestamp(ts.getTime()); if (getTimestampNanoPrecision() > 0) { int mask = (int)Math.pow(10, 9-getTimestampNanoPrecision()); newTs.setNanos(ts.getNanos()/mask*mask); } else { newTs.setNanos(0); } dateObject = newTs; } if (!useTimezone) { return dateObject.toString(); } return getTypeFacility().convertDate(dateObject, getDatabaseCalendar().getTimeZone(), TimestampWithTimezone.getCalendar(), dateObject.getClass()).toString(); }