Here you can find the source of formatDateHMSMZ(Date date)
Parameter | Description |
---|---|
dateString | a parameter |
Parameter | Description |
---|---|
ParseException | an exception |
public static String formatDateHMSMZ(Date date)
//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); } } }