フィールドタイプが Instant の pojo があります。TimsStamp から取得する Instant を設定したい。それは可能でしょうか?
例: にjava.sql.Timestamp
変換しjava.time.Instant.
たい がありますか?
フィールドタイプが Instant の pojo があります。TimsStamp から取得する Instant を設定したい。それは可能でしょうか?
例: にjava.sql.Timestamp
変換しjava.time.Instant.
たい がありますか?
Timestamp を Instant に、またはその逆に変換する既存のメソッドを用意しました。
Instant instant = Instant.now(); // get The current time in instant object
Timestamp t=java.sql.Timestamp.from(instant); // Convert instant to Timestamp
Instant anotherInstant=t.toInstant(); // Convert Timestamp to Instant
これをチェックして
この Timestamp オブジェクトを Instant に変換します。変換により、タイムライン上のこの Timestamp と同じ時点を表す Instant が作成されます。