Click here to watch on Youtube :
https://www.youtube.com/watch?v=L-za5SjSnSM&list=UUhwKlOVR041tngjerWxVccw
OffsetTimeDemo.java
Output
Click the below link to download the code:
https://sites.google.com/site/ramj2eev1/home/javabasics/OffsetTimeDemo_now_clock_zone.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/OffsetTimeDemo_now_clock_zone
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/6f1f0d2759f060503c7b9e4a4259ae3ddbfe139e/BasicJava/OffsetTimeDemo_now_clock_zone/?at=master
See also:
All JavaEE Videos Playlist
All JavaEE Videos
All JAVA EE Links
Servlets Tutorial
All Design Patterns Links
JDBC Tutorial
Java Collection Framework Tutorial
JAVA Tutorial
Kids Tutorial
https://www.youtube.com/watch?v=L-za5SjSnSM&list=UUhwKlOVR041tngjerWxVccw
OffsetTimeDemo.java
import java.time.Clock;
import java.time.OffsetTime;
import java.time.ZoneId;
public class OffsetTimeDemo
{
public static void main(String[] args)
{
Clock clock = Clock.systemUTC();
System.out.println(clock);
/*
* Parameters:
*
* clock - the clock to use, not null
*
* Returns:
*
* the current time, not null
*/
OffsetTime offsetTime1 = OffsetTime.now(clock);
System.out.println("offsetTime1 = " + offsetTime1);
ZoneId zoneId = ZoneId.systemDefault();
System.out.println(zoneId);
/*
* Parameters:
*
* zone - the zone ID to use, not null
*
* Returns:
*
* the current time using the system clock, not null
*/
OffsetTime offsetTime2 = OffsetTime.now(zoneId);
System.out.println("offsetTime2 = " + offsetTime2);
}
}
import java.time.OffsetTime;
import java.time.ZoneId;
public class OffsetTimeDemo
{
public static void main(String[] args)
{
Clock clock = Clock.systemUTC();
System.out.println(clock);
/*
* Parameters:
*
* clock - the clock to use, not null
*
* Returns:
*
* the current time, not null
*/
OffsetTime offsetTime1 = OffsetTime.now(clock);
System.out.println("offsetTime1 = " + offsetTime1);
ZoneId zoneId = ZoneId.systemDefault();
System.out.println(zoneId);
/*
* Parameters:
*
* zone - the zone ID to use, not null
*
* Returns:
*
* the current time using the system clock, not null
*/
OffsetTime offsetTime2 = OffsetTime.now(zoneId);
System.out.println("offsetTime2 = " + offsetTime2);
}
}
Output
SystemClock[Z]
offsetTime1 = 02:57:23.033Z
Asia/Calcutta
offsetTime2 = 08:27:48.717+05:30
offsetTime1 = 02:57:23.033Z
Asia/Calcutta
offsetTime2 = 08:27:48.717+05:30
Click the below link to download the code:
https://sites.google.com/site/ramj2eev1/home/javabasics/OffsetTimeDemo_now_clock_zone.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/OffsetTimeDemo_now_clock_zone
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/6f1f0d2759f060503c7b9e4a4259ae3ddbfe139e/BasicJava/OffsetTimeDemo_now_clock_zone/?at=master
See also:
No comments:
Post a Comment