Java UTC Date utcToDate(String utcTimestamp)

Here you can find the source of utcToDate(String utcTimestamp)

Description

utc To Date

License

Open Source License

Declaration

public static Date utcToDate(String utcTimestamp) throws ParseException 

Method Source Code

//package com.java2s;
/**//from  w ww  .jav a2 s  .c om
  * Copyright (c) 2009 University of Rochester
  *
  * This program is free software; you can redistribute it and/or modify it under the terms of the MIT/X11 license. The text of the  
  * license can be found at http://www.opensource.org/licenses/mit-license.php and copy of the license can be found on the project
  * website http://www.extensiblecatalog.org/. 
  *
  */

import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Date;

import java.util.TimeZone;

public class Main {
    public static Date utcToDate(String utcTimestamp) throws ParseException {
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
        df.setTimeZone(TimeZone.getTimeZone("GMT"));
        Date d = df.parse(utcTimestamp.replaceFirst("Z$", "+0000"));
        return d;
    }
}

Related

  1. toUTCString(Date date)
  2. toUTCString(long t)
  3. utcTime(Locale locale)
  4. utcTimestamp(Date date)
  5. utcTimeToString(String dateStr)
  6. utcToLocal(Date date)
  7. utcTolocal(String utc)