1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| As requested....
Self-contained simple code to demonstrate the problem?
i'm sending you the sample code with output..
import java.sql.Date;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.SimpleTimeZone;
import java.util.TimeZone;
public class TimeZoneTest {
public static void main(String[] args) {
SimpleDateFormat sdf = new SimpleDateFormat("h:mm a"); sdf.setCalendar(Calendar.getInstance(TimeZone.getTimeZone(TimeZone.getDefault().getID())));
System.out.println("System Time :" + sdf.format(new Date(System.currentTimeMillis())));
System.out.println("Default TZ:" + TimeZone.getDefault().getDisplayName(false, 1));
System.out.println("user.timezone="+System.getProperties().getProperty("user.timezone"));
System.out.println("OS ="+System.getProperties().getProperty("os.name"));
System.out.println("Java Version ="+System.getProperties().getProperty("java.version"));
}
}
this the out put in XP system
System Time :3:40 PM
Default TZ:India Standard Time
user.timezone=Asia/Calcutta
OS =Windows XP
Java Version =1.3.1
this is the output in Windows 7
System Time :10:09 AM
Default TZ:Greenwich Mean Time
user.timezone=GMT
OS =Windows NT (unknown)
Java Version =1.3.1_01 |
Partager