Java tutorial
//package com.java2s; import java.util.Date; public class Main { /** * * Return current date if not valid */ public static long parseLongDate(long timestamp, long defaultValue) { Date d = new Date(timestamp); return d == null ? defaultValue : d.getTime(); } }