Example usage for java.util Calendar getTimeZone

List of usage examples for java.util Calendar getTimeZone

Introduction

In this page you can find the example usage for java.util Calendar getTimeZone.

Prototype

public TimeZone getTimeZone() 

Source Link

Document

Gets the time zone.

Usage

From source file:helper.lang.DateHelperTest.java

@Test
public void testGetRangeDaysBeforeOneDay() {
    int days = 1;
    Calendar localtime = Calendar.getInstance();
    CalendarRange range = DateHelper.getRangeFullDaysBefore(localtime, days);
    Calendar start = range.getStart();
    Calendar end = range.getEnd();
    System.out.println(DateFormatUtils.SMTP_DATETIME_FORMAT.format(start));
    System.out.println(DateFormatUtils.SMTP_DATETIME_FORMAT.format(end));

    // end date is midnight of date passed in
    assertEquals(localtime.get(Calendar.YEAR), end.get(Calendar.YEAR));
    assertEquals(localtime.get(Calendar.MONTH), end.get(Calendar.MONTH));
    assertEquals(localtime.get(Calendar.DATE), end.get(Calendar.DATE));
    assertEquals(0, end.get(Calendar.HOUR));
    assertEquals(0, end.get(Calendar.MINUTE));
    assertEquals(0, end.get(Calendar.SECOND));
    assertEquals(0, end.get(Calendar.MILLISECOND));
    assertEquals(0, end.get(Calendar.HOUR_OF_DAY));
    assertEquals(DateHelper.UTC_TIME_ZONE, end.getTimeZone());

    // start date is 11:59:59 or 'days' time
    localtime.add(Calendar.DATE, -(days + 2)); //-1 is day before, -1 for day before day before, to include day before (> x)
    assertEquals(localtime.get(Calendar.YEAR), start.get(Calendar.YEAR));
    assertEquals(localtime.get(Calendar.MONTH), start.get(Calendar.MONTH));
    assertEquals(localtime.get(Calendar.DATE), start.get(Calendar.DATE));
    assertEquals(11, start.get(Calendar.HOUR));
    assertEquals(23, start.get(Calendar.HOUR_OF_DAY));
    assertEquals(59, start.get(Calendar.MINUTE));
    assertEquals(59, start.get(Calendar.SECOND));
    assertEquals(999, start.get(Calendar.MILLISECOND));
    assertEquals(DateHelper.UTC_TIME_ZONE, start.getTimeZone());
}

From source file:helper.lang.DateHelperTest.java

@Test
public void testGetRangeDaysBeforeTwoDays() {
    int days = 2;
    Calendar localtime = Calendar.getInstance();
    CalendarRange range = DateHelper.getRangeFullDaysBefore(localtime, days);
    Calendar start = range.getStart();
    Calendar end = range.getEnd();
    System.out.println(DateFormatUtils.SMTP_DATETIME_FORMAT.format(start));
    System.out.println(DateFormatUtils.SMTP_DATETIME_FORMAT.format(end));

    // end date is midnight of date passed in
    assertEquals(localtime.get(Calendar.YEAR), end.get(Calendar.YEAR));
    assertEquals(localtime.get(Calendar.MONTH), end.get(Calendar.MONTH));
    assertEquals(localtime.get(Calendar.DATE), end.get(Calendar.DATE));
    assertEquals(0, end.get(Calendar.HOUR));
    assertEquals(0, end.get(Calendar.MINUTE));
    assertEquals(0, end.get(Calendar.SECOND));
    assertEquals(0, end.get(Calendar.MILLISECOND));
    assertEquals(0, end.get(Calendar.HOUR_OF_DAY));
    assertEquals(DateHelper.UTC_TIME_ZONE, end.getTimeZone());

    // start date is 11:59:59 or 'days' time
    localtime.add(Calendar.DATE, -(days + 2));
    assertEquals(localtime.get(Calendar.YEAR), start.get(Calendar.YEAR));
    assertEquals(localtime.get(Calendar.MONTH), start.get(Calendar.MONTH));
    assertEquals(localtime.get(Calendar.DATE), start.get(Calendar.DATE));
    assertEquals(11, start.get(Calendar.HOUR));
    assertEquals(23, start.get(Calendar.HOUR_OF_DAY));
    assertEquals(59, start.get(Calendar.MINUTE));
    assertEquals(59, start.get(Calendar.SECOND));
    assertEquals(999, start.get(Calendar.MILLISECOND));
    assertEquals(DateHelper.UTC_TIME_ZONE, start.getTimeZone());
}

From source file:org.alfresco.repo.publishing.PublishingEventHelper.java

private Map<QName, Serializable> buildPublishingEventProperties(PublishingDetails details, String name) {
    Calendar schedule = details.getSchedule();
    if (schedule == null) {
        schedule = Calendar.getInstance();
    }//from   w ww. jav a 2s.  com
    Map<QName, Serializable> props = new HashMap<QName, Serializable>();
    props.put(ContentModel.PROP_NAME, name);
    props.put(PROP_PUBLISHING_EVENT_STATUS, Status.IN_PROGRESS.name());
    props.put(PROP_PUBLISHING_EVENT_TIME, schedule.getTime());
    props.put(PublishingModel.PROP_PUBLISHING_EVENT_TIME_ZONE, schedule.getTimeZone().getID());
    props.put(PublishingModel.PROP_PUBLISHING_EVENT_CHANNEL, details.getPublishChannelId());
    props.put(PublishingModel.PROP_PUBLISHING_EVENT_STATUS,
            PublishingModel.PROPVAL_PUBLISHING_EVENT_STATUS_SCHEDULED);
    String comment = details.getComment();
    if (comment != null) {
        props.put(PROP_PUBLISHING_EVENT_COMMENT, comment);
    }
    Collection<String> publshStrings = mapNodesToStrings(details.getNodesToPublish());
    props.put(PROP_PUBLISHING_EVENT_NODES_TO_PUBLISH, (Serializable) publshStrings);
    Collection<String> unpublshStrings = mapNodesToStrings(details.getNodesToUnpublish());
    props.put(PROP_PUBLISHING_EVENT_NODES_TO_UNPUBLISH, (Serializable) unpublshStrings);
    String message = details.getStatusMessage();
    Set<String> statusChannels = details.getStatusUpdateChannels();
    if (message != null && isEmpty(statusChannels) == false) {
        props.put(PROP_STATUS_UPDATE_MESSAGE, message);
        NodeRef statusNode = details.getNodeToLinkTo();
        if (statusNode != null) {
            props.put(PROP_STATUS_UPDATE_NODE_REF, statusNode.toString());
        }
        props.put(PROP_STATUS_UPDATE_CHANNEL_NAMES, (Serializable) statusChannels);
    }
    return props;
}

From source file:com.forrestguice.suntimeswidget.SuntimesUtils.java

/**
 * formats a time display string (lets the system determine the exact format).
 *
 * @param context a context//from   w  w w  . j  av  a  2s  . com
 * @param cal     a Calendar representing some point in time
 * @return a time display string (short format)
 */
public TimeDisplayText calendarTimeSysDisplayString(Context context, @NonNull Calendar cal) {
    DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(context);
    timeFormat.setTimeZone(cal.getTimeZone());
    TimeDisplayText retValue = new TimeDisplayText(timeFormat.format(cal.getTime()), "", "");
    retValue.setRawValue(cal.getTimeInMillis());
    return retValue;
}

From source file:org.apache.falcon.regression.core.bundle.Bundle.java

public Date getEndInstanceProcess(Calendar time) {
    ProcessMerlin processElement = getProcessObject();
    LOGGER.info("end instance: " + processElement.getInputs().getInputs().get(0).getEnd());
    LOGGER.info("timezone in getendinstance: " + time.getTimeZone().toString());
    LOGGER.info("time in getendinstance: " + time.getTime());
    return TimeUtil.getMinutes(processElement.getInputs().getInputs().get(0).getEnd(), time);
}

From source file:com.seajas.search.attender.service.attender.dao.ProfileDAO.java

/**
 * Find all notifiable subscribers from the given profile.
 * //from   ww  w .j  av a2  s. c o m
 * @param calendar
 * @param profile
 * @return List<ProfileSubscriber>
 */
public List<ProfileSubscriber> findNotifiableSubscribers(final Calendar calendar,
        final List<ProfileSubscriber> subscribers) {
    if (!calendar.getTimeZone().getID().equals("UTC"))
        throw new IllegalArgumentException(
                "The given calendar must have a UTC timezone (has " + calendar.getTimeZone().getID() + ")");

    // Calculate the current time in UTC

    Integer currentHour = calendar.get(Calendar.HOUR_OF_DAY), currentMinute = calendar.get(Calendar.MINUTE),
            currentDay = calendar.get(Calendar.DAY_OF_WEEK);
    Date currentTime = new Date(calendar.getTimeInMillis());

    // Return a list of all applicable subscribers for this profile

    List<ProfileSubscriber> result = new ArrayList<ProfileSubscriber>();

    // Find all active profiles' confirmed subscribers whose notification preference fall within the current day and whose time
    // values are greater than or equal to the current hour / minute; then take 7 days for weekly updates, 1 for daily updates,
    // and 1 for weekdays where Saturday / Sunday are excluded

    for (ProfileSubscriber subscriber : subscribers) {
        Integer subscriberDay = subscriber.getNotificationDay(),
                subscriberHour = subscriber.getNotificationHour(),
                subscriberMinute = subscriber.getNotificationMinute();
        Date lastNotification = subscriber.getLastNotification();
        NotificationType subscriberType = subscriber.getNotificationType();

        // Correct for the user-specific timezone

        TimeZone timeZone = TimeZone.getTimeZone(subscriber.getTimeZone());

        // Take leap seconds into account, although we're not so precise to really care

        if (subscriberMinute != null) {
            subscriberMinute -= (int) ((timeZone.getOffset(calendar.getTimeInMillis()) % MILLISECONDS_PER_HOUR)
                    / MILLISECONDS_PER_MINUTE);

            if (subscriberMinute < 0) {
                subscriberMinute += 60;
                subscriberHour--;
            } else if (subscriberMinute > 59) {
                subscriberMinute -= 60;
                subscriberHour++;
            }
        }

        if (subscriberHour != null) {
            subscriberHour -= (int) (timeZone.getOffset(calendar.getTimeInMillis()) / MILLISECONDS_PER_HOUR);

            if (subscriberHour < 0) {
                subscriberHour += 24;

                if (subscriberDay != null)
                    subscriberDay--;
            } else if (subscriberHour > 23) {
                subscriberHour -= 24;

                if (subscriberDay != null)
                    subscriberDay++;
            }
        }

        if (subscriberDay == -1)
            subscriberDay = 6;
        else if (subscriberDay == 7)
            subscriberDay = 0;

        // Now determine the actual applicability (last_notification is stored as a UTC date, so does not need to be converted)

        if (subscriber.getIsConfirmed() && ((subscriberType.equals(NotificationType.Weekly)
                && subscriberDay.equals(currentDay) && subscriberHour <= currentHour
                && subscriberMinute <= currentMinute && dateDifference(lastNotification, currentTime) >= 6)
                || (subscriberType.equals(NotificationType.Weekdays) && currentDay != Calendar.SATURDAY
                        && currentDay != Calendar.SUNDAY && subscriberHour <= currentHour
                        && subscriberMinute <= currentMinute
                        && !DateUtils.isSameDay(lastNotification, currentTime))
                || (subscriberType.equals(NotificationType.Daily) && subscriberHour <= currentHour
                        && subscriberMinute <= currentMinute
                        && !DateUtils.isSameDay(lastNotification, currentTime)))) {
            if (logger.isInfoEnabled())
                logger.info("Adding subscriber '" + subscriber.getUniqueId() + "' with e-mail '"
                        + subscriber.getEmail() + "' to be notified");

            result.add(subscriber);
        } else if (logger.isDebugEnabled()) {
            if (!subscriber.getIsConfirmed())
                logger.debug("Not adding subscriber '" + subscriber.getUniqueId() + "' with e-mail '"
                        + subscriber.getEmail() + "' - not confirmed");
            else if (subscriberType.equals(NotificationType.Direct))
                logger.debug("Not adding subscriber '" + subscriber.getUniqueId() + "' with e-mail '"
                        + subscriber.getEmail()
                        + "' - direct notifications are handled by search-enricher instances");
            else if (subscriberType.equals(NotificationType.Weekly)) {
                if (!subscriberDay.equals(currentDay))
                    logger.debug("Not adding subscriber '" + subscriber.getUniqueId() + "' with e-mail '"
                            + subscriber.getEmail() + "' - weekly notification does not fall on current day");
                if (!(subscriberHour <= currentHour && subscriberMinute <= currentMinute))
                    logger.debug("Not adding subscriber '" + subscriber.getUniqueId() + "' with e-mail '"
                            + subscriber.getEmail() + "' - weekly notification falls outside of current time");
                if (!(dateDifference(lastNotification, currentTime) >= 6))
                    logger.debug("Not adding subscriber '" + subscriber.getUniqueId() + "' with e-mail '"
                            + subscriber.getEmail()
                            + "' - weekly notification difference (in days) smaller than 7");
            } else if (subscriberType.equals(NotificationType.Weekdays)) {
                if (!(currentDay != Calendar.SATURDAY && currentDay != Calendar.SUNDAY))
                    logger.debug("Not adding subscriber '" + subscriber.getUniqueId() + "' with e-mail '"
                            + subscriber.getEmail() + "' - weekday notification does not fall on weekday");
                if (!(subscriberHour <= currentHour && subscriberMinute <= currentMinute))
                    logger.debug("Not adding subscriber '" + subscriber.getUniqueId() + "' with e-mail '"
                            + subscriber.getEmail() + "' - weekday notification falls outside of current time");
                if (DateUtils.isSameDay(lastNotification, currentTime))
                    logger.debug("Not adding subscriber '" + subscriber.getUniqueId() + "' with e-mail '"
                            + subscriber.getEmail()
                            + "' - weekday notification difference indicates a notification has already gone out today");
            } else if (subscriberType.equals(NotificationType.Daily)) {
                if (!(subscriberHour <= currentHour && subscriberMinute <= currentMinute))
                    logger.debug("Not adding subscriber '" + subscriber.getUniqueId() + "' with e-mail '"
                            + subscriber.getEmail() + "' - daily notification falls outside of current time");
                if (DateUtils.isSameDay(lastNotification, currentTime))
                    logger.debug("Not adding subscriber '" + subscriber.getUniqueId() + "' with e-mail '"
                            + subscriber.getEmail()
                            + "' - daily notification difference indicates a notification has already gone out today");
            }
        }
    }

    return result;
}

From source file:com.forrestguice.suntimeswidget.SuntimesUtils.java

public String calendarTime12HrString(Context context, @NonNull Calendar cal) {
    Locale locale = getLocale();/*from   w  ww.ja va  2  s.  c  om*/
    SimpleDateFormat timeFormat = new SimpleDateFormat(strTimeShortFormat12, locale); // h:mm a
    timeFormat.setTimeZone(cal.getTimeZone());
    return timeFormat.format(cal.getTime());
}

From source file:org.betaconceptframework.astroboa.test.engine.AbstractRepositoryTest.java

protected String convertCalendarToXMLFormat(Calendar calendar, boolean dateTimePattern) {
     if (dateTimePattern) {
         GregorianCalendar gregCalendar = new GregorianCalendar(calendar.getTimeZone());
         gregCalendar.setTimeInMillis(calendar.getTimeInMillis());

         return df.newXMLGregorianCalendar(gregCalendar).toXMLFormat();
     } else {/*from   w  w w  . j a  va2s . c  om*/
         return df.newXMLGregorianCalendarDate(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1, // Calendar.MONTH is zero based, XSD Date datatype's month field starts
                 //   with JANUARY as 1.
                 calendar.get(Calendar.DAY_OF_MONTH), DatatypeConstants.FIELD_UNDEFINED).toXMLFormat();
     }
 }

From source file:com.mirth.connect.model.util.ImportConverter.java

private static String convertChannel(Document document) throws Exception {
    String channelXML = "";
    Element channelRoot = document.getDocumentElement();

    String version = channelRoot.getElementsByTagName("version").item(0).getTextContent();

    int majorVersion = Integer.parseInt(version.split("\\.")[0]);
    int minorVersion = Integer.parseInt(version.split("\\.")[1]);
    int patchVersion = Integer.parseInt(version.split("\\.")[2]);

    if (majorVersion < 2) {
        if (minorVersion < 4) {
            Direction direction = null;/* ww  w  . j  av  a2 s.com*/
            Element sourceConnectorRoot = (Element) document.getDocumentElement()
                    .getElementsByTagName("sourceConnector").item(0);
            Element destinationConnectorRoot = (Element) document.getDocumentElement()
                    .getElementsByTagName("destinationConnectors").item(0);
            NodeList destinationsConnectors = getElements(destinationConnectorRoot, "connector",
                    "com.mirth.connect.model.Connector");

            Node channelDirection = channelRoot.getElementsByTagName("direction").item(0);

            if (channelDirection.getTextContent().equals("INBOUND"))
                direction = Direction.INBOUND;
            else if (channelDirection.getTextContent().equals("OUTBOUND"))
                direction = Direction.OUTBOUND;

            channelRoot.removeChild(channelDirection);

            NodeList modeElements = channelRoot.getElementsByTagName("mode");

            for (int i = 0; i < modeElements.getLength(); i++) {
                if (((Element) modeElements.item(i)).getParentNode() == channelRoot) {
                    channelRoot.removeChild(modeElements.item(i));
                }
            }

            channelRoot.removeChild(channelRoot.getElementsByTagName("protocol").item(0));

            NodeList transportNames = channelRoot.getElementsByTagName("transportName");
            for (int i = 0; i < transportNames.getLength(); i++) {
                if (transportNames.item(i).getTextContent().equals("PDF Writer")) {
                    transportNames.item(i).setTextContent("Document Writer");
                }
            }

            NodeList properyNames = channelRoot.getElementsByTagName("property");
            for (int i = 0; i < properyNames.getLength(); i++) {
                Node nameAttribute = properyNames.item(i).getAttributes().getNamedItem("name");
                if (properyNames.item(i).getAttributes().getLength() > 0 && nameAttribute != null) {
                    if (nameAttribute.getNodeValue().equals("DataType")) {
                        if (properyNames.item(i).getTextContent().equals("PDF Writer")) {
                            properyNames.item(i).setTextContent("Document Writer");
                        }
                    }
                }
            }

            Element modeElement = document.createElement("mode");
            modeElement.setTextContent("SOURCE");
            sourceConnectorRoot.appendChild(modeElement);

            updateFilterFor1_4((Element) sourceConnectorRoot.getElementsByTagName("filter").item(0));
            if (direction == Direction.OUTBOUND)
                updateTransformerFor1_4(document,
                        (Element) sourceConnectorRoot.getElementsByTagName("transformer").item(0), XML, XML);
            else
                updateTransformerFor1_4(document,
                        (Element) sourceConnectorRoot.getElementsByTagName("transformer").item(0), HL7V2,
                        HL7V2);

            for (int i = 0; i < destinationsConnectors.getLength(); i++) {
                modeElement = document.createElement("mode");
                modeElement.setTextContent("DESTINATION");

                Element destinationsConnector = (Element) destinationsConnectors.item(i);
                destinationsConnector.appendChild(modeElement);

                updateFilterFor1_4((Element) destinationsConnector.getElementsByTagName("filter").item(0));

                if (direction == Direction.OUTBOUND)
                    updateTransformerFor1_4(document,
                            (Element) destinationsConnector.getElementsByTagName("transformer").item(0), XML,
                            HL7V2);
                else
                    updateTransformerFor1_4(document,
                            (Element) destinationsConnector.getElementsByTagName("transformer").item(0), HL7V2,
                            HL7V2);

            }
        }

        if (minorVersion < 5) {
            updateTransformerFor1_5(document);
        }

        if (minorVersion < 6) {
            // Go through each connector and set it to enabled if that
            // property doesn't exist.

            Element sourceConnectorRoot = (Element) document.getDocumentElement()
                    .getElementsByTagName("sourceConnector").item(0);
            Element destinationConnectorRoot = (Element) document.getDocumentElement()
                    .getElementsByTagName("destinationConnectors").item(0);
            NodeList destinationsConnectors = getElements(destinationConnectorRoot, "connector",
                    "com.mirth.connect.model.Connector");

            // Check SOURCE CONNECTOR node for "enabled" element which is
            // added by migration automatically. Add it if not found.
            if (!nodeChildrenContains(sourceConnectorRoot, "enabled")) {
                Element enabledSource = document.createElement("enabled");
                enabledSource.setTextContent("true");
                sourceConnectorRoot.appendChild(enabledSource);
            } else {
                // set it anyway, in case xstream auto set it to false.
                setBooleanNode(sourceConnectorRoot, "enabled", true);
            }

            // Check CONNECTOR node for "enabled" element which is added by
            // migration automatically. Add it if not found.
            for (int i = 0; i < destinationsConnectors.getLength(); i++) {
                Element destinationConnector = (Element) destinationsConnectors.item(i);

                if (!nodeChildrenContains(destinationConnector, "enabled")) {
                    Element enabledDestination = document.createElement("enabled");
                    enabledDestination.setTextContent("true");
                    destinationConnector.appendChild(enabledDestination);
                } else {
                    // set it anyway, in case xstream auto set it to false.
                    setBooleanNode(destinationConnector, "enabled", true);
                }
            }

            if (!nodeChildrenContains(channelRoot, "deployScript")) {
                Element deployScript = document.createElement("deployScript");
                deployScript.setTextContent(
                        "// This script executes once when the channel is deployed\n// You only have access to the globalMap and globalChannelMap here to persist data\nreturn;");
                channelRoot.appendChild(deployScript);
            }

            if (!nodeChildrenContains(channelRoot, "shutdownScript")) {
                Element shutdownScript = document.createElement("shutdownScript");
                shutdownScript.setTextContent(
                        "// This script executes once when the channel is undeployed\n// You only have access to the globalMap and globalChannelMap here to persist data\nreturn;");
                channelRoot.appendChild(shutdownScript);
            }

            if (!nodeChildrenContains(channelRoot, "postprocessingScript")) {
                Element postprocessorScript = document.createElement("postprocessingScript");
                postprocessorScript.setTextContent(
                        "// This script executes once after a message has been processed\nreturn;");
                channelRoot.appendChild(postprocessorScript);
            }
        }

        if (minorVersion < 7) {
            if (!nodeChildrenContains(channelRoot, "lastModified")) {
                Element lastModified = document.createElement("lastModified");
                Element time = document.createElement("time");
                Element timezone = document.createElement("timezone");

                Calendar calendar = Calendar.getInstance();
                time.setTextContent(calendar.getTimeInMillis() + "");
                timezone.setTextContent(calendar.getTimeZone().getDisplayName());

                lastModified.appendChild(time);
                lastModified.appendChild(timezone);

                channelRoot.appendChild(lastModified);
            }

            updateFilterFor1_7(document);
            updateTransformerFor1_7(document);
        }

        if (minorVersion < 8) {
            // Run for all versions prior to 1.7.1
            if (minorVersion < 7 || (minorVersion == 7 && patchVersion < 1)) {
                updateTransformerFor1_7_1(document);
            }
            convertChannelConnectorsFor1_8(document, channelRoot);
        }

        // Run for all versions prior to 1.8.2
        if (minorVersion < 8 || (minorVersion == 8 && patchVersion < 1)) {
            updateTransformerFor1_8_1(document);
        }

        // Run for all versions prior to 2.0

        // MIRTH-1402 - Fix old channels from oracle that did not have
        // description because they were blank
        if (channelRoot.getElementsByTagName("description").getLength() == 0) {
            Element descriptionElement = document.createElement("description");
            channelRoot.appendChild(descriptionElement);
        }

        convertChannelConnectorsFor2_0(document, channelRoot);
        updateFilterFor2_0(document);
    }

    // Run for all versions prior to 3.x
    if (majorVersion < 3) {
        // Run for all versions prior to 2.2
        if (minorVersion < 2) {
            convertChannelConnectorsFor2_2(document, channelRoot);
        }
    }

    DocumentSerializer docSerializer = new DocumentSerializer();
    channelXML = docSerializer.toXML(document);

    return updateLocalAndGlobalVariables(channelXML);
}

From source file:net.sourceforge.msscodefactory.cflib.v1_11.CFLib.CFLibXmlUtil.java

public static String formatTZTimestamp(Calendar cal) {
    final String S_ProcName = "formatTZTimestamp";
    if (cal == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(CFLibXmlUtil.class, S_ProcName, 1,
                "cal");
    }//www. j  a v a2s. c  o  m
    StringBuffer buff = new StringBuffer();
    Formatter fmt = new Formatter(buff);
    fmt.format("%1$04d", cal.get(Calendar.YEAR));
    buff.append('-');
    fmt.format("%1$02d", cal.get(Calendar.MONTH) + 1);
    buff.append('-');
    fmt.format("%1$02d", cal.get(Calendar.DAY_OF_MONTH));
    buff.append('T');
    fmt.format("%1$02d", cal.get(Calendar.HOUR_OF_DAY));
    buff.append(':');
    fmt.format("%1$02d", cal.get(Calendar.MINUTE));
    buff.append(':');
    fmt.format("%1$02d", cal.get(Calendar.SECOND));
    int tzoff = cal.getTimeZone().getRawOffset() / 60000;
    if (tzoff < 0) {
        tzoff = 0 - tzoff;
        buff.append('-');
    } else {
        buff.append('+');
    }
    int tzhour = tzoff / 60;
    int tzmin = tzoff % 60;
    if (tzhour > 12) {
        fmt.close();
        throw CFLib.getDefaultExceptionFactory().newInvalidArgumentException(CFLibXmlUtil.class, S_ProcName, 0,
                "tzhour", tzhour);
    }
    fmt.format("%1$02d", tzhour);
    buff.append(':');
    fmt.format("%1$02d", tzmin);
    String retval = buff.toString();
    fmt.close();
    return (retval);
}