convert date to EST

how to convert the date to EST time zone?what is EDT?

Thu May 12 12:32:33 EDT 2015
LVL 20
chaitu chaituAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
EST is the daylight saving version of EDT. As it happens, that style of timezone id is deprecated. Use the America/X version, e.g. America/New_York

SimpleDateFormat (see API docs) allows you to set a TimeZone
0
chaitu chaituAuthor Commented:
is it correct?

DateFormat df1 = new SimpleDateFormat("EEE MMM d hh:mm:ss z yyyy");
                         Date dt= df1.parse("Thu May 12 12:32:33 EDT 2015");
                         df1.setTimeZone(TimeZone.getTimeZone("US/Eastern"));

                         String result = df1.format(dt);
0
CEHJCommented:
If you're creating a Date, you don't need to set a TimeZone on the DateFormat, unless you're converting. It's difficult  to see what your goal is

http://technojeeves.com/index.php/aliasjava1/15-smart-questions
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

rrzCommented:
is it correct?
Your code looks ok. But, you probably want to use "America/New_York"
0
chaitu chaituAuthor Commented:
issue is one server is in UTC time zone and another server is in EST time zone.

the request is coming from the UTC time zone and the object is  in the form of xmlgregoriancalendar object.i want to convert into EST time zone and save it into DB.
0
CEHJCommented:
It's conceivable that you only need to change the XMLGregorianCalendar timezone
http://docs.oracle.com/javase/7/docs/api/javax/xml/datatype/XMLGregorianCalendar.html#setTimezone(int)
0
chaitu chaituAuthor Commented:
how to convert EST time zone in INT..
0
CEHJCommented:
Try
import java.util.*;


public class Offset {
    public static void main(String[] args) {
        TimeZone tz = null;

        if (args.length < 1) {
            tz = TimeZone.getDefault();
        } else {
            tz = TimeZone.getTimeZone(args[0]);
        }

        final int HOURS_IN_MILLISECOND = 1000 * 60 * 60;
        System.out.printf("Raw offset (hours) = %d. Daylight saving now? %b%n",
            tz.getRawOffset() / HOURS_IN_MILLISECOND,
            tz.inDaylightTime(new Date()));
    }
}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CEHJCommented:
:)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.