Monday 2 July 2018

How to use valueOf(String name) method of DayOfWeek Enum | Java 8 Date and Time


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

DayOfWeekDemo.java

import java.time.DayOfWeek;

public class DayOfWeekDemo
{
    public static void main(String[] args)
    {
        /*
         * Parameters:
         *
         * name - the name of the enum constant to be returned.
         *
         * Returns:
         *
         * the enum constant with the specified name
         */

        DayOfWeek dayOfWeek = DayOfWeek.valueOf("FRIDAY");
        System.out.println("dayOfWeek = " + dayOfWeek);
    }

}

Output

dayOfWeek = FRIDAY

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

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

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/bb275a728500f81507bdd46f6424332d29623c06/BasicJava_2018/DayOfWeekDemo_valueOf/?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