Android Date to UTC Convert getDateInUTC(String date)

Here you can find the source of getDateInUTC(String date)

Description

get Date In UTC

License

Apache License

Declaration

public static Date getDateInUTC(String date) throws ParseException 

Method Source Code

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

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

import java.util.TimeZone;

public class Main {
    public static Date getDateInUTC(String date) throws ParseException {
        return getCalendarInUTC(date).getTime();
    }/* w w  w. jav a  2 s  .  c om*/

    public static Calendar getCalendarInUTC(String date)
            throws ParseException {
        Calendar calendar = Calendar.getInstance(TimeZone
                .getTimeZone("UTC"));
        SimpleDateFormat fromDateFormat = new SimpleDateFormat(
                "yyyy-MM-dd HH:mm:ss");
        calendar.setTime(fromDateFormat.parse(date));
        return calendar;
    }
}

Related

  1. nowUTC()
  2. localDateToUTC(Date dtLocal)
  3. currentDateInUTC()
  4. getCalendarInUTC(String date)