Click here to watch on Youtube:
https://www.youtube.com/watch?v=qUyoIW4WezI&list=UUhwKlOVR041tngjerWxVccw
DurationDemo.java
Output
Click the below link to download the code:
https://sites.google.com/site/ramj2eev2/java_basics/DurationDemo_isNegative_zero.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava_2018/DurationDemo_isNegative_zero
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/8497cbe1b661ade036f769d804f96b3ba18763d5/BasicJava_2018/DurationDemo_isNegative_zero/?at=master
See also:
https://www.youtube.com/watch?v=qUyoIW4WezI&list=UUhwKlOVR041tngjerWxVccw
DurationDemo.java
import java.time.Duration;
import java.time.LocalTime;
public class DurationDemo
{
public static void main(String[] args)
{
Duration duration = Duration.between(LocalTime.NOON,
LocalTime.MIDNIGHT);
System.out.println("duration = "+duration);
/*
* Returns:true if this duration has a total length less than
* zero
*/
System.out.println("is duration Negative? = "+duration.isNegative());
/*
* Returns:true if this duration has a total length equal to
* zero
*/
System.out.println("is duration zero? = "+duration.isZero());
}
}
import java.time.LocalTime;
public class DurationDemo
{
public static void main(String[] args)
{
Duration duration = Duration.between(LocalTime.NOON,
LocalTime.MIDNIGHT);
System.out.println("duration = "+duration);
/*
* Returns:true if this duration has a total length less than
* zero
*/
System.out.println("is duration Negative? = "+duration.isNegative());
/*
* Returns:true if this duration has a total length equal to
* zero
*/
System.out.println("is duration zero? = "+duration.isZero());
}
}
Output
duration = PT-12H
is duration Negative? = true
is duration zero? = false
is duration Negative? = true
is duration zero? = false
Click the below link to download the code:
https://sites.google.com/site/ramj2eev2/java_basics/DurationDemo_isNegative_zero.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava_2018/DurationDemo_isNegative_zero
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/8497cbe1b661ade036f769d804f96b3ba18763d5/BasicJava_2018/DurationDemo_isNegative_zero/?at=master
See also:
No comments:
Post a Comment