Click here to watch on Youtube :
https://www.youtube.com/watch?v=hNTL0nYaKKA&list=UUhwKlOVR041tngjerWxVccw
MonthDayDemo.java
Output
Click the below link to download the code:
https://sites.google.com/site/ramj2eev1/home/javabasics/MonthDayDemo_getmonth_day.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/MonthDayDemo_getmonth_day
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/0341b02de53fb9c08ccad77af304766fda93a105/BasicJava/MonthDayDemo_getmonth_day/?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=hNTL0nYaKKA&list=UUhwKlOVR041tngjerWxVccw
MonthDayDemo.java
import java.time.Month;
import java.time.MonthDay;
public class MonthDayDemo
{
public static void main(String[] args)
{
/*
* Returns:the current month-day using the system clock and
* default time-zone, not null
*/
MonthDay monthDay = MonthDay.now();
System.out.println("monthDay = " + monthDay);
/*
* Returns:the day-of-month, from 1 to 31
*/
int dayOfTheMonth = monthDay.getDayOfMonth();
System.out.println("dayOfTheMonth = " + dayOfTheMonth);
/*
* Returns:the month-of-year, from 1 to 12
*/
int monthValue = monthDay.getMonthValue();
System.out.println("monthValue = " + monthValue);
/*
* Returns:the month-of-year, not null
*/
Month month = monthDay.getMonth();
System.out.println("month = " + month);
System.out.println("month value = " + month.getValue());
}
}
import java.time.MonthDay;
public class MonthDayDemo
{
public static void main(String[] args)
{
/*
* Returns:the current month-day using the system clock and
* default time-zone, not null
*/
MonthDay monthDay = MonthDay.now();
System.out.println("monthDay = " + monthDay);
/*
* Returns:the day-of-month, from 1 to 31
*/
int dayOfTheMonth = monthDay.getDayOfMonth();
System.out.println("dayOfTheMonth = " + dayOfTheMonth);
/*
* Returns:the month-of-year, from 1 to 12
*/
int monthValue = monthDay.getMonthValue();
System.out.println("monthValue = " + monthValue);
/*
* Returns:the month-of-year, not null
*/
Month month = monthDay.getMonth();
System.out.println("month = " + month);
System.out.println("month value = " + month.getValue());
}
}
Output
monthDay = --01-18
dayOfTheMonth = 18
monthValue = 1
month = JANUARY
month value = 1
dayOfTheMonth = 18
monthValue = 1
month = JANUARY
month value = 1
Click the below link to download the code:
https://sites.google.com/site/ramj2eev1/home/javabasics/MonthDayDemo_getmonth_day.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/MonthDayDemo_getmonth_day
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/0341b02de53fb9c08ccad77af304766fda93a105/BasicJava/MonthDayDemo_getmonth_day/?at=master
See also:
No comments:
Post a Comment