Click here to watch on Youtube:
https://www.youtube.com/watch?v=huu96XG-jeQ&list=UUhwKlOVR041tngjerWxVccw
YearDemo1.java
Output
YearDemo2.java
Output
Click the below link to download the code:
https://sites.google.com/site/ramj2eev2/java_basics/YearDemo_isAfter_before_getValue.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava_2018/YearDemo_isAfter_before_getValue
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/8e3f14caa10b52912934997a22df069c728f47b4/BasicJava_2018/YearDemo_isAfter_before_getValue/?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=huu96XG-jeQ&list=UUhwKlOVR041tngjerWxVccw
YearDemo1.java
import java.time.Year;
public class YearDemo1
{
public static void main(String[] args)
{
Year year1 = Year.of(2017);
System.out.println("year1 = "+year1);
Year year2 = Year.of(2014);
System.out.println("year2 = "+year2);
/*
* Parameters:
*
* other - the other year to compare to, not null
*
* Returns:
*
* true if this is after the specified year
*/
boolean result = year1.isAfter(year2);
System.out.println(year1+" is after "+year2+" = "+result);
/*
* Parameters:
*
* other - the other year to compare to, not null
*
* Returns:
*
* true if this point is before the specified year
*/
result = year1.isBefore(year2);
System.out.println(year1+" is before "+year2+" = "+result);
}
}
public class YearDemo1
{
public static void main(String[] args)
{
Year year1 = Year.of(2017);
System.out.println("year1 = "+year1);
Year year2 = Year.of(2014);
System.out.println("year2 = "+year2);
/*
* Parameters:
*
* other - the other year to compare to, not null
*
* Returns:
*
* true if this is after the specified year
*/
boolean result = year1.isAfter(year2);
System.out.println(year1+" is after "+year2+" = "+result);
/*
* Parameters:
*
* other - the other year to compare to, not null
*
* Returns:
*
* true if this point is before the specified year
*/
result = year1.isBefore(year2);
System.out.println(year1+" is before "+year2+" = "+result);
}
}
Output
year1 = 2017
year2 = 2014
2017 is after 2014 = true
2017 is before 2014 = false
year2 = 2014
2017 is after 2014 = true
2017 is before 2014 = false
YearDemo2.java
import java.time.Year;
public class YearDemo2
{
public static void main(String[] args)
{
Year year = Year.of(2017);
/*
* Returns:
*
* the year, MIN_VALUE to MAX_VALUE
*/
int yearValue = year.getValue();
System.out.println(yearValue);
}
}
public class YearDemo2
{
public static void main(String[] args)
{
Year year = Year.of(2017);
/*
* Returns:
*
* the year, MIN_VALUE to MAX_VALUE
*/
int yearValue = year.getValue();
System.out.println(yearValue);
}
}
Output
2017
Click the below link to download the code:
https://sites.google.com/site/ramj2eev2/java_basics/YearDemo_isAfter_before_getValue.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava_2018/YearDemo_isAfter_before_getValue
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/8e3f14caa10b52912934997a22df069c728f47b4/BasicJava_2018/YearDemo_isAfter_before_getValue/?at=master
See also:
No comments:
Post a Comment