Tuesday 30 January 2018

How to form LocalDate using atYear method of MonthDay Class | Java 8 Date and Time

MonthDayDemo.java

import java.time.LocalDate;
import java.time.MonthDay;

public class MonthDayDemo
{

    public static void main(String[] args)
    {
        MonthDay monthDay = MonthDay.now();
        System.out.println(monthDay);

        /*
         * Parameters:
         *
         * year - the year to use, from MIN_YEAR to MAX_YEAR
         *
         * Returns:
         *
         * the local date formed from this month-day and the
         * specified year, not null
         */

        LocalDate localDate = monthDay.atYear(2013);
        System.out.println(localDate);
    }
}

Output

--01-18
2013-01-18

Click the below link to download the code:
https://sites.google.com/site/ramj2eev1/home/javabasics/MonthDayDemo_atYear.zip?attredirects=0&d=1

Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/MonthDayDemo_atYear

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/8fa516d67356209c67bf6743dfb7e718c4c9e5f6/BasicJava/MonthDayDemo_atYear/?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
  • No comments:

    Post a Comment