Click here to watch on Youtube:
https://www.youtube.com/watch?v=mgro4Td2-es&list=UUhwKlOVR041tngjerWxVccw
TimeZoneDemo.java
Output
Click the below link to download the code:
https://sites.google.com/site/javaspringram2019/java_spring_2019/TimeZoneDemo_setDefault.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java_Spring_2019/tree/master/Java_2019/TimeZoneDemo_setDefault
Bitbucket Link:
https://bitbucket.org/ramram43210/java_spring_2019/src/80d90bcf5505788c0f100e330fb6b354d3132ddb/Java_2019/TimeZoneDemo_setDefault/?at=master
See also:
All JavaEE Videos Playlist
All JavaEE Videos
All JAVA EE Links
Spring Tutorial
Servlets Tutorial
All Design Patterns Links
JDBC Tutorial
Java Collection Framework Tutorial
JAVA Tutorial
Kids Tutorial
Cooking Tutorial
https://www.youtube.com/watch?v=mgro4Td2-es&list=UUhwKlOVR041tngjerWxVccw
TimeZoneDemo.java
import java.util.TimeZone;
public class TimeZoneDemo
{
public static void main(String[] args)
{
TimeZone defaultTimeZone = TimeZone.getDefault();
System.out.println("Before Set, defaultTimeZone = " + defaultTimeZone);
TimeZone timeZone = TimeZone.getTimeZone("America/Los_Angeles");
/*
* Parameters:
*
* zone - the new default TimeZone, or null
*/
TimeZone.setDefault(timeZone);
defaultTimeZone = TimeZone.getDefault();
System.out.println("\nAfter Set, defaultTimeZone = " + defaultTimeZone);
}
}
public class TimeZoneDemo
{
public static void main(String[] args)
{
TimeZone defaultTimeZone = TimeZone.getDefault();
System.out.println("Before Set, defaultTimeZone = " + defaultTimeZone);
TimeZone timeZone = TimeZone.getTimeZone("America/Los_Angeles");
/*
* Parameters:
*
* zone - the new default TimeZone, or null
*/
TimeZone.setDefault(timeZone);
defaultTimeZone = TimeZone.getDefault();
System.out.println("\nAfter Set, defaultTimeZone = " + defaultTimeZone);
}
}
Output
Before Set, defaultTimeZone = sun.util.calendar.ZoneInfo[id="Asia/Calcutta",offset=19800000,dstSavings=0,useDaylight=false,transitions=6,lastRule=null]
After Set, defaultTimeZone = sun.util.calendar.ZoneInfo[id="America/Los_Angeles",offset=-28800000,dstSavings=3600000,useDaylight=true,transitions=185,lastRule=java.util.SimpleTimeZone[id=America/Los_Angeles,offset=-28800000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,endMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]]
After Set, defaultTimeZone = sun.util.calendar.ZoneInfo[id="America/Los_Angeles",offset=-28800000,dstSavings=3600000,useDaylight=true,transitions=185,lastRule=java.util.SimpleTimeZone[id=America/Los_Angeles,offset=-28800000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,endMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]]
Click the below link to download the code:
https://sites.google.com/site/javaspringram2019/java_spring_2019/TimeZoneDemo_setDefault.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java_Spring_2019/tree/master/Java_2019/TimeZoneDemo_setDefault
Bitbucket Link:
https://bitbucket.org/ramram43210/java_spring_2019/src/80d90bcf5505788c0f100e330fb6b354d3132ddb/Java_2019/TimeZoneDemo_setDefault/?at=master
See also:
No comments:
Post a Comment