Java Date to Time toXSDDateTime(Date date)

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

Description

to XSD Date Time

License

Apache License

Declaration

public static String toXSDDateTime(Date date) 

Method Source Code


//package com.java2s;
/*/*ww  w  . j  a v a 2  s. co  m*/
 * Copyright 2008-2010 Digital Enterprise Research Institute (DERI)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {
    public static String toXSDDateTime(Date date) {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
        String s = simpleDateFormat.format(date);
        StringBuilder sb = new StringBuilder(s);
        sb.insert(22, ':');
        return sb.toString();
    }
}

Related

  1. toTimeString(Date date)
  2. toTimeString(Date date)
  3. toTimeString(Date dateTime)
  4. toTimeString(Date time)
  5. toUIDateTimeString(Date d)
  6. toXSDDateTimeString(Date d)