Click here to watch on Youtube :
https://www.youtube.com/watch?v=T8IskeGazzA&list=UUhwKlOVR041tngjerWxVccw
OffsetTimeDemo.java
import java.time.LocalTime;
import java.time.OffsetTime;
import java.time.ZoneOffset;
public class OffsetTimeDemo
{
public static void main(String[] args)
{
/*
* Parameters:
*
* hour - the hour-of-day to represent, from 0 to 23
*
* minute - the minute-of-hour to represent, from 0 to 59
*
* second - the second-of-minute to represent, from 0 to 59
*
* nanoOfSecond - the nano-of-second to represent, from 0 to
* 999,999,999
*
* offset - the zone offset, not null
*
* Returns:
*
* the offset time, not null
*/
OffsetTime offsetTime1 = OffsetTime.of(6, 30, 40, 50000,
ZoneOffset.UTC);
System.out.println("offsetTime1 = " + offsetTime1);
LocalTime localTime = LocalTime.now();
/*
* Parameters:
*
* time - the local time, not null
*
* offset - the zone offset, not null
*
* Returns:
*
* the offset time, not null
*/
OffsetTime offsetTime2 = OffsetTime.of(localTime, ZoneOffset.UTC);
System.out.println("offsetTime2 = " + offsetTime2);
}
}
import java.time.OffsetTime;
import java.time.ZoneOffset;
public class OffsetTimeDemo
{
public static void main(String[] args)
{
/*
* Parameters:
*
* hour - the hour-of-day to represent, from 0 to 23
*
* minute - the minute-of-hour to represent, from 0 to 59
*
* second - the second-of-minute to represent, from 0 to 59
*
* nanoOfSecond - the nano-of-second to represent, from 0 to
* 999,999,999
*
* offset - the zone offset, not null
*
* Returns:
*
* the offset time, not null
*/
OffsetTime offsetTime1 = OffsetTime.of(6, 30, 40, 50000,
ZoneOffset.UTC);
System.out.println("offsetTime1 = " + offsetTime1);
LocalTime localTime = LocalTime.now();
/*
* Parameters:
*
* time - the local time, not null
*
* offset - the zone offset, not null
*
* Returns:
*
* the offset time, not null
*/
OffsetTime offsetTime2 = OffsetTime.of(localTime, ZoneOffset.UTC);
System.out.println("offsetTime2 = " + offsetTime2);
}
}
Output
offsetTime1 = 06:30:40.000050Z
offsetTime2 = 07:51:57.581Z
offsetTime2 = 07:51:57.581Z
Click the below link to download the code:
https://sites.google.com/site/ramj2eev1/home/javabasics/OffsetTimeDemo_of_methods.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/OffsetTimeDemo_of_methods
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/6f1f0d2759f060503c7b9e4a4259ae3ddbfe139e/BasicJava/OffsetTimeDemo_of_methods/?at=master
See also:
No comments:
Post a Comment