Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static Double fromDate(Date date) {
- if (date==null) {
- return(null);
- }
- Long d = date.getTime()/1000;
- return(d.doubleValue());
- }
- public static Date toDate(Double millisSinceEpoch) {
- if (millisSinceEpoch==null) {
- return(null);
- }
- Long d = Math.round(millisSinceEpoch*1000);
- return(new Date(d));
- }
- public static String toDateString(Double millisSinceEpoch){
- Date date = toDate(millisSinceEpoch);
- String pattern = "yyyy-MM-dd";
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
- return simpleDateFormat.format(date);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement