Java SQL Time From toTime(LocalTime localTime)

Here you can find the source of toTime(LocalTime localTime)

Description

to Time

License

Apache License

Declaration

public static Time toTime(LocalTime localTime) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.sql.Time;

import java.time.LocalDate;

import java.time.LocalTime;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;

public class Main {
    public static Time toTime(LocalTime localTime) {
        if (localTime == null) {
            return null;
        }/*from w w w .j  a v a 2  s .c o m*/
        return new Time(
                Time.from(ZonedDateTime.of(LocalDate.now(), localTime, ZoneOffset.systemDefault()).toInstant())
                        .getTime());
    }
}

Related

  1. toTime(Date value)
  2. toTime(final Date date)
  3. toTime(final Object value)
  4. toTime(int value)
  5. toTime(java.util.GregorianCalendar cal)
  6. toTime(LocalTime localTime)
  7. toTime(Object object, Object oDefault)
  8. toTime(Object value)
  9. toTime(String format, String str)