Java Date Format As formatDateHMSMZ(Date date)

Here you can find the source of formatDateHMSMZ(Date date)

Description

Transform the Java to XML Schema format for the timezone.

License

Open Source License

Parameter

Parameter Description
dateString a parameter

Exception

Parameter Description
ParseException an exception

Declaration

public static String formatDateHMSMZ(Date date) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2012 Firestar Software, Inc.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:/*from  w  w  w. j  ava 2 s  . c  o m*/
 *     Firestar Software, Inc. - initial API and implementation
 *
 * Author:
 *     Gabriel Oancea
 *
 *******************************************************************************/

import java.util.*;

import java.text.*;

public class Main {
    private static final SimpleDateFormat HMSMZ = new SimpleDateFormat(
            "HH:mm:ss.SSSZ");

    /**
     * Transform the Java to XML Schema format for the timezone.
     * <p>
     * <code>0123456789012345678901234567890</code>
     * <p>
     * <code>HH:mm:ss.SSS-0500</code> to
     * <p>
     * <code>HH:mm:ss.SSS-05:00</code>
     * <p>
     * 
     * @param dateString
     * @return
     * @throws ParseException
     */
    public static String formatDateHMSMZ(Date date) {
        synchronized (HMSMZ) {
            String dateString = HMSMZ.format(date);
            return dateString.substring(0, 15) + ":"
                    + dateString.substring(15);
        }
    }
}

Related

  1. formatDateForXpath(Date date)
  2. formatDateGMT(Date date)
  3. formatDateHeader(final Date date)
  4. formatDateHeader(final Date date)
  5. formatDateHMS(java.util.Date date)
  6. formatDateList(List dateList)
  7. formatDateMedium(Date date)
  8. formatDatemhs(java.util.Date date)
  9. formatDateMonth(Date d)