Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. public static Double fromDate(Date date) {
  2. if (date==null) {
  3. return(null);
  4. }
  5. Long d = date.getTime()/1000;
  6. return(d.doubleValue());
  7. }
  8.  
  9. public static Date toDate(Double millisSinceEpoch) {
  10. if (millisSinceEpoch==null) {
  11. return(null);
  12. }
  13.  
  14. Long d = Math.round(millisSinceEpoch*1000);
  15. return(new Date(d));
  16. }
  17. public static String toDateString(Double millisSinceEpoch){
  18. Date date = toDate(millisSinceEpoch);
  19. String pattern = "yyyy-MM-dd";
  20. SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
  21. return simpleDateFormat.format(date);
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement