Java Date Format Change changeDateTimeZone(String date_GMT)

Here you can find the source of changeDateTimeZone(String date_GMT)

Description

change Date Time Zone

License

Apache License

Declaration

public static String changeDateTimeZone(String date_GMT) throws ParseException 

Method Source Code

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

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

import java.util.TimeZone;

public class Main {
    private static final TimeZone timeZone = TimeZone.getTimeZone("GMT-4:00");

    public static String changeDateTimeZone(String date_GMT) throws ParseException {
        DateFormat format = new SimpleDateFormat("M/d/yyyy hh:mm:ss a");
        format.setTimeZone(TimeZone.getTimeZone("GMT"));

        Date date = format.parse(date_GMT);
        format.setTimeZone(timeZone);/*from  w  w  w  .  j a v  a2s  .  co  m*/
        return format.format(date);

    }
}

Related

  1. changeDateFormat(String dateString, String srcFormat, String destFormat)
  2. changeDateFormatPattern(final DateFormat dateFormat, String regex, String replacement)
  3. changeDateValue(Date firstDate, Date secondDate)
  4. convertDate(String date, String sourceFormat, String destinationFormat)
  5. convertDate(String date, String[] formats)
  6. convertDate(String dateIn, String fromDateFormat, String toDateFormat)