A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/java/time-class-in-java-sql/ below:

Time class in Java SQL

Time class in Java SQL

Last Updated : 26 Oct, 2018

Time class

is a part of

Java SQL package

.This class is a thin wrapper around java.util.Date that allows JDBC API to identify this as a SQL TIME value. The initial value of time is set to 1st January, 1970. All values of time after that is positive and time before that is negative.

Class Hierarchy:
java.lang.Object
  ↳ java.util.Date
      ↳ java.sql.Time 
Constructors:
  1. Time(long t): creates a Time object using a milliseconds time value.
Example to demonstrate how to create object of Time Class using Constructor: Java
// Java program to demonstrate
// Constructor of Time Class

import java.sql.*;

class GFG {
    public static void main(String args[])
    {
        // time in milliseconds
        long milli = 123456789999l;

        // create a object
        java.sql.Time time = new java.sql.Time(milli);

        // display the time
        System.out.println("Time = " + time.toString());
    }
}
Methods: Method Explanation setTime(long t) sets the value of time using milliseconds toString() Formats a time in JDBC time escape format. valueOf(String s) Converts a string in JDBC time escape format to a Time value.

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4