Here you can find the source of getNotNullTimestampValue(String timestamp, String format)
public static Timestamp getNotNullTimestampValue(String timestamp, String format)
//package com.java2s; //License from project: Apache License import java.sql.Timestamp; import java.text.SimpleDateFormat; public class Main { public static Timestamp getNotNullTimestampValue(String timestamp, String format) { Timestamp value;/*w ww . j a v a2s .co m*/ try { if (timestamp == null || timestamp.equals("")) { value = new Timestamp(System.currentTimeMillis()); } else { SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format); value = new Timestamp(simpleDateFormat.parse(timestamp).getTime()); } } catch (Exception e) { e.printStackTrace(); value = new Timestamp(System.currentTimeMillis()); } return value; } }