Java UTC Date stringToUTC(String utc)

Here you can find the source of stringToUTC(String utc)

Description

Converts a UTC date/time string to a UTC date/time value.

License

Open Source License

Parameter

Parameter Description
utc the UTC date/time string

Declaration

public static Date stringToUTC(String utc) throws ParseException 

Method Source Code


//package com.java2s;
/*/*from  w w  w.  j  a va  2s.c  o  m*/
 * Copyright (C) 2010 Brockmann Consult GmbH (info@brockmann-consult.de)
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 3 of the License, or (at your option)
 * any later version.
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, see http://www.gnu.org/licenses/
 */

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

public class Main {
    /**
     * An ISO 8601 date/time format.
     */
    public static final SimpleDateFormat ISO_8601_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");

    /**
     * Converts a UTC date/time string to a UTC date/time value. The method uses the ISO 8601 date/time format
     * <code>YYYY-MM-DD hh:mm:ss.S</code>
     * <p><i>Important note:</i> Due to the limitations of {@link java.util.Date java.util.Date} this method does not
     * take leap seconds into account.
     *
     * @param utc the UTC date/time string
     */
    public static Date stringToUTC(String utc) throws ParseException {
        return ISO_8601_FORMAT.parse(utc);
    }
}

Related

  1. getUTCTimeString4Digits(Date date)
  2. nowInUTC()
  3. nowUtc(String pattern)
  4. nowUTCString()
  5. SerializeUtc(Date dt)
  6. toUTCDate(String dateStr)
  7. toUTCString(Date date)
  8. toUTCString(long t)
  9. utcTime(Locale locale)