This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes Problem with Calendar, Locale,TimeZone Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Problem with Calendar, Locale,TimeZone" Watch "Problem with Calendar, Locale,TimeZone" New topic
Author

Problem with Calendar, Locale,TimeZone

Rajesh Hegde
Ranch Hand

Joined: Sep 15, 2000
Posts: 112
Hi all,
I am trying to get the date in a country based on its time zone and locale. I have used the getInstance method of the "Calendar" Class passing the Locale and time zone as parameters. But Some how it shows the the timezone and locale of the system. Can any one tell me how to get a solution for my problem.
Rajesh
Here is the code for more info :
import java.util.*;
class TestTime
{
public static void main(String a[])
{
SimpleTimeZone TZ=new SimpleTimeZone(18000000,"India");
// 18000000 milliseconds is the difference wrt to GMT
Locale india=new Locale("hi","IN");
Calendar cal=Calendar.getInstance(TZ,india);
System.out.println("Date: = " + cal.getTime());
}
}
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Problem with Calendar, Locale,TimeZone
 
Similar Threads
settimezone on gregorian calendar doesn't work !!
calendar time viewed by differing timezone
calendar.getInstance()
calendar timezone
Get date and time using TimeZone.