Advertisement
Guest User

Untitled

a guest
Nov 12th, 2015
15
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. package com.squareup.JooqTest;
  2.  
  3. import java.sql.Timestamp;
  4. import java.time.Instant;
  5. import org.jooq.Converter;
  6.  
  7. public class TimestampConverter implements Converter<Timestamp, Integer> {
  8. @Override public Integer from(Timestamp timestamp) {
  9. return (int)timestamp.toInstant().getEpochSecond();
  10. }
  11.  
  12. @Override public Timestamp to(Integer value) {
  13. return Timestamp.from(Instant.ofEpochSecond(value));
  14. }
  15.  
  16. @Override public Class<Timestamp> fromType() {
  17. return Timestamp.class;
  18. }
  19.  
  20. @Override public Class<Integer> toType() {
  21. return Integer.class;
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement