Java Utililty Methods Timestamp Create

List of utility methods to do Timestamp Create

Description

The list of methods to do Timestamp Create are organized into topic(s).

Method

java.sql.TimetoSqlTime(Timestamp timestamp)
to Sql Time
return new java.sql.Time(timestamp.getTime());
TimestamptoSqlTimestamp(Date d)
to Sql Timestamp
return new Timestamp(d.getTime());
TimestamptoSqlTimeStamp(Date d)
to Sql Time Stamp
if (d == null)
    return null;
return new java.sql.Timestamp(d.getTime());
java.sql.TimestamptoSQLTimestamp(Date date)
Convert a java.util.date in a java.sql.timestamp, in order to store the information in a jdbc database
java.sql.Timestamp timestamp = new java.sql.Timestamp(date.getTime());
return timestamp;
java.sql.TimestamptoSQLTimestamp(DateTime dt)
to SQL Timestamp
java.sql.Timestamp ts = (dt == null ? null : new java.sql.Timestamp(dt.getMillis()));
return ts;
java.sql.TimestamptoSqlTimestamp(java.util.Date date)
to Sql Timestamp
if (date == null) {
    return null;
return toSqlTimestamp(date.getTime());
java.sql.TimestamptoSQLTimestamp(Object object, Object oDefault)
to SQL Timestamp
if (object == null) {
    if (oDefault == null)
        return null;
    return toSQLTimestamp(oDefault, null);
if (object instanceof java.sql.Timestamp) {
    return (java.sql.Timestamp) object;
if (object instanceof java.util.Date) {
    return new java.sql.Timestamp(((java.util.Date) object).getTime());
if (object instanceof java.util.Calendar) {
    return new java.sql.Timestamp(((java.util.Calendar) object).getTimeInMillis());
if (object instanceof Long) {
    return new java.sql.Timestamp(((Long) object).longValue());
if (object instanceof Number) {
    int iDate = ((Number) object).intValue();
    if (iDate < 10000)
        return toSQLTimestamp(oDefault, null);
    return new java.sql.Timestamp(intToLongDate(iDate));
if (object instanceof Collection) {
    return toSQLTimestamp(getFirst(object), oDefault);
if (object.getClass().isArray()) {
    return toSQLTimestamp(getFirst(object), oDefault);
if (object instanceof Map) {
    return toSQLTimestamp(oDefault, null);
String sValue = object.toString();
if (sValue == null || sValue.length() == 0)
    return toSQLTimestamp(oDefault, null);
Date time = stringToTime(sValue);
if (time == null)
    return toSQLTimestamp(oDefault, null);
return new java.sql.Timestamp(time.getTime());
java.sql.TimestamptoSQLTimestamp(String time)
To SQL timestamp.
return java.sql.Timestamp.valueOf(time);
TimestamptoTimestamp(BigDecimal value)
to Timestamp
long seconds = value.longValue();
int nanoseconds = extractNanosecondDecimal(value, seconds);
Timestamp ts = new Timestamp(seconds * 1000);
ts.setNanos(nanoseconds);
return ts;
TimestamptoTimestamp(Date date)
to Timestamp
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.set(Calendar.MILLISECOND, 0);
return new Timestamp(calendar.getTimeInMillis());