Wednesday 14 November 2018

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


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

SqlDateDemo.java

import java.sql.Date;

public class SqlDateDemo
{
    public static void main(String[] args)
    {
        String strDate = "2018-05-25";

        /*
         * Parameters:s -
         *
         * a String object representing a date in in the format
         * "yyyy-[m]m-[d]d". The leading zero for mm and dd may also
         * be omitted.
         *
         * Returns:
         *
         * a java.sql.Date object representing the given date
         */

        Date date = Date.valueOf(strDate);
        System.out.println(date);
    }

}

Output

2018-05-25

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

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

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