Java UTC Date toUTCDate(String dateStr)

Here you can find the source of toUTCDate(String dateStr)

Description

to UTC Date

License

Apache License

Declaration

public static Date toUTCDate(String dateStr) throws ParseException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

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

import java.util.Locale;
import java.util.TimeZone;

public class Main {
    public static final String TIME_ZONE_UTC_GMT = "+0000";
    private static final String DATE_TIME_FORMAT = "EEE MMM dd HH:mm:ss ZZZZZ yyyy";

    public static Date toUTCDate(String dateStr) throws ParseException {
        SimpleDateFormat format = new SimpleDateFormat(DATE_TIME_FORMAT, Locale.ENGLISH);

        format.setTimeZone(TimeZone.getTimeZone(TIME_ZONE_UTC_GMT));
        return format.parse(dateStr);
    }//from  w  ww .j a v  a 2 s  .co m
}

Related

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