Here you can find the source of stringToUTC(String utc)
Parameter | Description |
---|---|
utc | the UTC date/time string |
public static Date stringToUTC(String utc) throws ParseException
//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); } }