Laire
Laire

Reputation: 1330

Getting date from another timezone

How can I change the timezone, when I use this code to get the date?

    Calendar c = Calendar.getInstance();
    String date = org.apache.http.impl.cookie.DateUtils.formatDate(c.getTime());

This returns me the date in my timezone (GMT+00:00) but I need the CET time.

Upvotes: 0

Views: 46

Answers (1)

Khantahr
Khantahr

Reputation: 8528

Use the setTimeZone method on your calendar to set the time zone to CET.

c.setTimeZone( "Europe/Amsterdam" );

Upvotes: 1

Related Questions