Thursday 15 November 2018

How to use valueOf(LocalTime time) method of java.sql.Time class | Java Date and Time


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

TimeDemo.java

import java.sql.Time;
import java.time.LocalTime;

public class TimeDemo
{

    public static void main(String[] args)
    {

        LocalTime localTime = LocalTime.now();
        System.out.println("localTime = " + localTime);

        /*
         * Obtains an instance of Time from a LocalTime object with
         * the same hour, minute and second time value as the given
         * LocalTime.
         *
         * Parameters:
         *
         * time - a LocalTime to convert
         *
         * Returns:
         *
         * a Time object
         */

        Time time = Time.valueOf(localTime);
        System.out.println("time = " + time);

    }

}

Output

localTime = 09:58:01.935
time = 09:58:01

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

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

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