I have this Time
object:
Time myTime = java.sql.Time.valueOf("15:33:00");
How can I add 30 minutes to myTime
in Java? That means the new time will be 16:03:00
Use the ADDTIME() function if you want to select a new datetime by adding a given time to a datetime/timestamp/time value. This function takes two arguments.
java.sql.Time. A thin wrapper around the java. util. Date class that allows the JDBC API to identify this as an SQL TIME value. The Time class adds formatting and parsing operations to support the JDBC escape syntax for time values.
No time data is kept. In fact, the date is stored as milliseconds since the 1st of January 1970 00:00:00 GMT and the time part is normalized, i.e. set to zero.
java.sql.Time myTime = java.sql.Time.valueOf("15:33:00");
LocalTime localtime = myTime.toLocalTime();
localtime = localtime.plusMinutes(30);
String output = localtime.toString();
you can get localTime straight away from the java.sql.time and you can use plusMinutes in LocalTime Api to add 30 minutes. this might help you check this
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With