Click here to watch on Youtube:
https://www.youtube.com/watch?v=HIUZaQnzwhU&list=UUhwKlOVR041tngjerWxVccw
YearMonthDemo.java
Output
Click the below link to download the code:
https://sites.google.com/site/ramj2eev2/java_basics/YearMonthDemo_isAfter_before.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava_2018/YearMonthDemo_isAfter_before
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/b8bbbd8e3fa258805c096cde7ca05dcc526111c2/BasicJava_2018/YearMonthDemo_isAfter_before/?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
Cooking Tutorial
https://www.youtube.com/watch?v=HIUZaQnzwhU&list=UUhwKlOVR041tngjerWxVccw
YearMonthDemo.java
import java.time.YearMonth;
public class YearMonthDemo
{
public static void main(String[] args)
{
YearMonth yearMonth1 = YearMonth.of(2016, 03);
System.out.println("yearMonth1 = "+yearMonth1);
YearMonth yearMonth2 = YearMonth.of(2017, 03);
System.out.println("yearMonth2 = "+yearMonth2);
/*
* Parameters:
*
* other - the other year-month to compare to, not null
*
* Returns:
*
* true if this is after the specified year-month
*/
boolean result = yearMonth1.isAfter(yearMonth2);
System.out.println(yearMonth1+" is after "+yearMonth2+" = "+result);
/*
* Parameters:
*
* other - the other year-month to compare to, not null
*
* Returns:
*
* true if this point is before the specified year-month
*/
result = yearMonth1.isBefore(yearMonth2);
System.out.println(yearMonth1+" is before "+yearMonth2+" = "+result);
}
}
public class YearMonthDemo
{
public static void main(String[] args)
{
YearMonth yearMonth1 = YearMonth.of(2016, 03);
System.out.println("yearMonth1 = "+yearMonth1);
YearMonth yearMonth2 = YearMonth.of(2017, 03);
System.out.println("yearMonth2 = "+yearMonth2);
/*
* Parameters:
*
* other - the other year-month to compare to, not null
*
* Returns:
*
* true if this is after the specified year-month
*/
boolean result = yearMonth1.isAfter(yearMonth2);
System.out.println(yearMonth1+" is after "+yearMonth2+" = "+result);
/*
* Parameters:
*
* other - the other year-month to compare to, not null
*
* Returns:
*
* true if this point is before the specified year-month
*/
result = yearMonth1.isBefore(yearMonth2);
System.out.println(yearMonth1+" is before "+yearMonth2+" = "+result);
}
}
Output
yearMonth1 = 2016-03
yearMonth2 = 2017-03
2016-03 is after 2017-03 = false
2016-03 is before 2017-03 = true
yearMonth2 = 2017-03
2016-03 is after 2017-03 = false
2016-03 is before 2017-03 = true
Click the below link to download the code:
https://sites.google.com/site/ramj2eev2/java_basics/YearMonthDemo_isAfter_before.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava_2018/YearMonthDemo_isAfter_before
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/b8bbbd8e3fa258805c096cde7ca05dcc526111c2/BasicJava_2018/YearMonthDemo_isAfter_before/?at=master
See also:
No comments:
Post a Comment