List of utility methods to do Timestamp Create
Timestamp | toTimestamp(String str, String format) to Timestamp if (str == null) { return null; try { return new Timestamp(parseDate(str, format).getTime()); } catch (Exception e) { return null; |
Timestamp | toTimestamp(String value) to Timestamp return Timestamp.valueOf(value);
|
Timestamp | toTimestamp(String yyyymmddhhmmss) to Timestamp if (yyyymmddhhmmss == null) { return null; String year = yyyymmddhhmmss.substring(0, 4); if (Integer.valueOf(year) > 2400) { year = String.valueOf(Integer.parseInt(year) - 543); String month = yyyymmddhhmmss.substring(4, 6); ... |
java.sql.Timestamp | toTimestamp2(long seconds, int fraction, int width) to Timestamp return timestamp2ToTimestamp(seconds, fraction, width);
|
Timestamp | toTimestamp2(long seconds, int nanos) to Timestamp final java.sql.Timestamp r = new java.sql.Timestamp(seconds * 1000L); r.setNanos(nanos); return r; |
String | toTimestamp2(long value, int nanos, int meta) to Timestamp SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Timestamp time = new java.sql.Timestamp(value * 1000L); String strValue = sdf.format(time); return strValue + microSecondToStr(nanos, meta); |
Timestamp | toTimestampByHour(Date date, int hour) to Timestamp By Hour String h = Integer.toString(hour); if (h.length() == 1) h = "0" + h; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); String now = sdf.format(date); String endDate = now + " " + h + ":00:00"; SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Timestamp timpestamp = null; ... |
Timestamp | toTimestampFromGMT(int yy, int mm, int dd, int hh, int mi, int ss) to Timestamp From GMT return toTimestampFromGMT(String.valueOf(yy), String.valueOf(mm), String.valueOf(dd), String.valueOf(hh),
String.valueOf(mi), String.valueOf(ss));
|
Timestamp | toTimestampFromLong(long millis) Returns the Timestamp corresponding to millis , which denotes the point in time that many milliseconds since the epoch; returns null if millis is negative.
if (millis < 0) { return null; return new Timestamp(millis); |
Timestamp | toTimestampFromTime(String time) to Timestamp From Time try { return toTimestampFromTime(Long.parseLong(time)); } catch (Exception iae) { return null; |