0

How can I convert a String value to java.sql.time?

I have a scenario in which user gives the input time value as string.

For example: 10 PM

I have to store this value in Database as time stamp. Could any one please help me solving this problem. Mainly I want to write the getter and setter for this scenario.

2
  • How about a "google search" ? Commented May 8, 2015 at 5:39
  • 1
    See my Answer on a similar Question, using the modern java.time.LocalTime class. Commented Nov 23, 2022 at 22:45

1 Answer 1

1

try this

    String t = "10:34:34";
    Time time = Time.valueOf(t);
    System.out.println(time);

its working.

Sign up to request clarification or add additional context in comments.

1 Comment

Update: The java.sql.Time class has been supplanted by the modern java.time classes defined in JSR 310. Replaced specifically by java.time.LocalTime.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.