Skip to content

Instantly share code, notes, and snippets.

@SubhrajyotiSen
Created June 15, 2017 05:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SubhrajyotiSen/523d8652b165714904e0e6d595a0b655 to your computer and use it in GitHub Desktop.
Save SubhrajyotiSen/523d8652b165714904e0e6d595a0b655 to your computer and use it in GitHub Desktop.
import java.util.Date;
class DateConverter {
@TypeConverter
public static Date toDate(Long timestamp) {
return timestamp == null ? null : new Date(timestamp);
}
@TypeConverter
public static Long toTimestamp(Date date) {
return date == null ? null : date.getTime();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment