Discard a row in sql time

How do we insert a string into a time type with mysql in java So the string is -------> java.sql.time

thank.

+3
source share
3 answers

It completely depends on the format of yours String, so I would use SimpleDateFormatto parse the string in java.util.Date; then you can extract the millisecond time value from this date and pass it to java.sql.Time(). Like this:

String s = /* your date string here */;
SimpleDateFormat sdf = new SimpleDateFormat(/* your date format string here */);
long ms = sdf.parse(s).getTime();
Time t = new Time(ms);
+8
source
java.sql.Time.valueOf("String");
+8
source

:

java.sql.Time.parse("String");

DateFormat Parse http://java.sun.com/j2se/1.4.2/docs/api/java/text/DateFormat.html

+2

All Articles