Friday 8 June 2018

How to use from(TemporalAccessor temporal) method of DayOfWeek Enum | Java 8 Date and Time


Click here to watch on Youtube:
https://www.youtube.com/watch?v=22KijZEvo4M&list=UUhwKlOVR041tngjerWxVccw

DayOfWeekDemo.java

import java.time.DayOfWeek;
import java.time.LocalDate;

public class DayOfWeekDemo
{
    public static void main(String[] args)
    {

        LocalDate localDate = LocalDate.now();
        System.out.println("localDate = "+localDate);
       
        /*
         * Parameters:
         *
         * temporal - the temporal object to convert, not null
         *
         * Returns:
         *
         * the day-of-week, not null
         */

        DayOfWeek dayOfWeek = DayOfWeek.from(localDate);
        System.out.println("dayOfWeek = "+dayOfWeek);
    }

}

Output

localDate = 2018-04-29
dayOfWeek = SUNDAY

Click the below link to download the code:
https://sites.google.com/site/ramj2eev2/java_basics/DayOfWeekDemo_from.zip?attredirects=0&d=1

Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava_2018/DayOfWeekDemo_from

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/23d89f367bac9ed4230eafe0abaf49c0a80cc445/BasicJava_2018/DayOfWeekDemo_from/?at=master

See also:
  • All JavaEE Videos Playlist
  • All JavaEE Videos
  • All JAVA EE Links
  • Spring Tutorial
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • Kids Tutorial
  • Cooking Tutorial
  • No comments:

    Post a Comment