Java Date to Time toExtendedTime(Date date)

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

Description

Formats the time portion of the given date in ISO8601 compatible format with delimiters.

License

Open Source License

Parameter

Parameter Description
date the date object to convert.

Return

String representing the time portion of the date in HH:mm:ss format.

Declaration

public static String toExtendedTime(Date date) 

Method Source Code

//package com.java2s;
/*//from  w  ww.j a  v a2 s.  c  om
 * Copyright (c) 2004 Stephan D. Cote' - All rights reserved.
 * 
 * This program and the accompanying materials are made available under the 
 * terms of the MIT License which accompanies this distribution, and is 
 * available at http://creativecommons.org/licenses/MIT/
 *
 * Contributors:
 *   Stephan D. Cote 
 *      - Initial API and implementation
 */

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    /**
     * Formats the time portion of the given date in ISO8601 compatible format
     * with delimiters.
     *
     * @param date the date object to convert.
     *
     * @return String representing the time portion of the date in HH:mm:ss
     *         format.
     */
    public static String toExtendedTime(Date date) {
        SimpleDateFormat formatter = new SimpleDateFormat("HH':'mm':'ss");
        return formatter.format(date);
    }
}

Related

  1. removeTime(Date date)
  2. serializeDateTime(final Date date)
  3. serializeXsdDateTime(Date date)
  4. strTime(Date dt)
  5. to24HrTimeString(Date date)
  6. toGeneralizedTime(Date date)
  7. toLocalDateTime(Date date)
  8. toLocalTimeString(Date d)
  9. toMT4TimeString(Date date)