java.sql

Class Timestamp

Implemented Interfaces:
Cloneable, Comparable<T>, Serializable

public class Timestamp
extends Date

A thin wrapper around java.util.Date that allows the JDBC API to identify this as an SQL TIMESTAMP value. It adds the ability to hold the SQL TIMESTAMP nanos value and provides formatting and parsing operations to support the JDBC escape syntax for timestamp values.

Note: This type is a composite of a java.util.Date and a separate nanoseconds value. Only integral seconds are stored in the java.util.Date component. The fractional seconds - the nanos - are separate. The Timestamp.equals(Object) method never returns true when passed a value of type java.util.Date because the nanos component of a date is unknown. As a result, the Timestamp.equals(Object) method is not symmetric with respect to the java.util.Date.equals(Object) method. Also, the hashcode method uses the underlying java.util.Date implementation and therefore does not include nanos in its computation.

Due to the differences between the Timestamp class and the java.util.Date class mentioned above, it is recommended that code not view Timestamp values generically as an instance of java.util.Date. The inheritance relationship between Timestamp and java.util.Date really denotes implementation inheritance, and not type inheritance.

See Also:
Serialized Form

Constructor Summary

Timestamp(long time)
Constructs a Timestamp object using a milliseconds time value.

Method Summary

boolean
after(Timestamp ts)
Indicates whether this Timestamp object is later than the given Timestamp object.
boolean
before(Timestamp ts)
Indicates whether this Timestamp object is earlier than the given Timestamp object.
int
compareTo(Timestamp ts)
Compares this Timestamp object to the given Timestamp object.
int
compareTo(Date o)
Compares this Timestamp object to the given Date, which must be a Timestamp object.
boolean
equals(Object ts)
Tests to see if this Timestamp object is equal to the given object.
boolean
equals(Timestamp ts)
Tests to see if this Timestamp object is equal to the given Timestamp object.
int
getNanos()
Gets this Timestamp object's nanos value.
long
getTime()
Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this Timestamp object.
void
setNanos(int n)
Sets this Timestamp object's nanos field to the given value.
void
setTime(long time)
Sets this Timestamp object to represent a point in time that is time milliseconds after January 1, 1970 00:00:00 GMT.
String
toString()
Formats a timestamp in JDBC timestamp escape format.
static Timestamp
valueOf(String s)
Converts a String object in JDBC timestamp escape format to a Timestamp value.

Methods inherited from class java.util.Date

String toGMTString, String toLocaleString, after, before, clone, compareTo, equals, getTime, hashCode, int getDate, int getDay, int getHours, int getMinutes, int getMonth, int getSeconds, int getTimezoneOffset, int getYear, long UTC, long parse, setTime, toString, void setDate, void setHours, void setMinutes, void setMonth, void setSeconds, void setYear

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

Timestamp

public Timestamp(long time)
Constructs a Timestamp object using a milliseconds time value. The integral seconds are stored in the underlying date value; the fractional seconds are stored in the nanos field of the Timestamp object.
Parameters:
time - milliseconds since January 1, 1970, 00:00:00 GMT. A negative number is the number of milliseconds before January 1, 1970, 00:00:00 GMT.
Usages and Demos :

View More Examples of Timestamp(long time)
   1:     out.println("else");
   2:     out.println("  " + pstmt + ".setTimestamp(" + index + "++, new java.sql.Timestamp(" + value + ".getTimeInMillis()));");
   3:   }
   4:         ...
   5:     Timestamp timestamp
   6:       = new Timestamp(((Calendar) value).getTimeInMillis());
   7: 
   8:     switch (_temporalType) {
   9:     case DATE:

View Full Code Here
   1:     out.println("else");
   2:     out.println("  " + pstmt + ".setTimestamp(" + index + "++, new java.sql.Timestamp(" + value + ".getTime()));");
   3:   }
   4: 
   5:   public static java.util.Date toDate(java.sql.Timestamp time)

View Full Code Here
   1:         } else if (object.getClass() == ClassConstants.TIMESTAMP) {
   2:             printString("new java.sql.Timestamp(");
   3:             printString(String.valueOf(((java.sql.Timestamp)object).getTime()));
   4:             printString("L)");
   5:         } else if (object.getClass() == ClassConstants.SQLDATE) {

View Full Code Here
   1:             if (obj instanceof Number) {
   2:                 u.setProperty("lastlogin", new Timestamp(((Number)obj).longValue()));
   3:             } else if (obj instanceof Date) {
   4:         ...
   5:                 u.setProperty("lastlogin", new Timestamp(((Date)obj).getTime()));
   6:             }
   7:         }
   8:         if (userdata.containsKey("friendslist")) {

View Full Code Here
   1:         } else if(value instanceof Number) {
   2:             return new Timestamp(((Number)value).longValue());
   3:         } else {
   4:         }
   5:     }

View Full Code Here

Method Details

after

public boolean after(Timestamp ts)
Indicates whether this Timestamp object is later than the given Timestamp object.
Parameters:
ts - the Timestamp value to compare with
Returns:
true if this Timestamp object is later; false otherwise

before

public boolean before(Timestamp ts)
Indicates whether this Timestamp object is earlier than the given Timestamp object.
Parameters:
ts - the Timestamp value to compare with
Returns:
true if this Timestamp object is earlier; false otherwise
Usages and Demos :

View More Examples of before(Timestamp ts)
   1: 
   2: import java.sql.Timestamp;
   3: import java.util.Collections;
   4:         ...
   5: 
   6:   public List storageByDateSince(final Timestamp date) {
   7:     return QueryKit.query(storage.storageAll(), new SnipQuery() {
   8:         ...
   9:       public boolean fit(Snip snip) {
  10:         return (date.before(snip.getMTime()));
  11:       }

View Full Code Here
   1:       
   2:       Timestamp deadline;
   3:       SimpleDateFormat df = new SimpleDateFormat("MMM dd, yyyy h:mm a");
   4:         ...
   5:     log.paranoid("Begin Method.","Exam:elapsedMinutes");
   6:     Timestamp dateTaken=null;
   7:     log.paranoid("dateTaken (should be null): " + dateTaken,"Homework:elapsedMinutes");
   8:         ...
   9:   boolean deadlinePassed(Student student,int assignmentNumber) {
  10:     Timestamp deadline = null;
  11:     int sectionID = student.sectionID;

View Full Code Here
   1:       
   2:       Timestamp deadline;
   3:       SimpleDateFormat df = new SimpleDateFormat("MMM dd, yyyy h:mm a");
   4:         ...
   5:   int elapsedMinutes(int code){
   6:     Timestamp dateTaken=null;
   7:     int ret;
   8:         ...
   9:   boolean deadlinePassed(Student student,int assignmentNumber) {
  10:     Timestamp deadline = null;
  11:     int sectionID = student.sectionID;

View Full Code Here
   1:       
   2:       Timestamp deadline;
   3:       MessageFormat mf = new MessageFormat(res.getString("str_timed_interval"));
   4:         ...
   5: 
   6:           Timestamp available = rs.getTimestamp("Available");
   7:         ...
   8:           if (allowWorkAhead || available.before(now) || student.getIsInstructor()) {
   9:             
  10:         ...
  11:     log.paranoid("Begin Method.","Exam:elapsedMinutes");
  12:     Timestamp dateTaken=null;

View Full Code Here

compareTo

public int compareTo(Timestamp ts)
Compares this Timestamp object to the given Timestamp object.
Parameters:
ts - the Timestamp object to be compared to this Timestamp object
Returns:
the value 0 if the two Timestamp objects are equal; a value less than 0 if this Timestamp object is before the given argument; and a value greater than 0 if this Timestamp object is after the given argument.
Since:
1.2
Usages and Demos :

View More Examples of compareTo(Timestamp ts)
   1: 
   2: import java.sql.Timestamp;
   3: 
   4:         ...
   5:     private boolean success;
   6:     private Timestamp timestamp;
   7: 
   8:         ...
   9:         Archive archive = (Archive)o;
  10:         return timestamp.compareTo(archive.timestamp);
  11:     }

View Full Code Here
   1: 
   2: import java.sql.Timestamp;
   3: 
   4:         ...
   5:     private String details;
   6:     private Timestamp timestamp;
   7: 
   8:         ...
   9:         Log log = (Log)o;
  10:         int diff = activity.compareTo(log.activity);
  11:         if (diff != 0)
  12:         ...
  13:             return diff;
  14:         return timestamp.compareTo(log.timestamp);

View Full Code Here
   1: import java.math.BigDecimal;
   2: import java.sql.Timestamp;
   3: import java.util.Comparator;
   4:         ...
   5:             String s = (String)cmp1;
   6:             return s.compareTo((String)cmp2) * m_multiplier;
   7:         }
   8:         ...
   9:         else if (cmp1 instanceof Timestamp && cmp2 instanceof Timestamp)
  10:         {
  11:         ...
  12:             Timestamp t = (Timestamp)cmp1;
  13:             return t.compareTo((Timestamp)cmp2) * m_multiplier;

View Full Code Here
   1: import java.util.*;
   2: import java.sql.Timestamp;
   3: import oracle.toplink.essentials.expressions.*;
   4:         ...
   5:     public int compareWriteLockValues(Object value1, Object value2) {
   6:         java.sql.Timestamp timestampValue1 = (java.sql.Timestamp)value1;
   7:         java.sql.Timestamp timestampValue2 = (java.sql.Timestamp)value2;
   8:         ...
   9:         return timestampValue1.compareTo(timestampValue2);
  10:     }

View Full Code Here
   1: import java.sql.Time;
   2: import java.sql.Timestamp;
   3: import java.util.Collection;
   4:         ...
   5:       ((HashMap) objectValue).put("time", timeValue);
   6:       ((HashMap) objectValue).put("timestamp", timestampValue);
   7:       ((HashMap) objectValue).put("bigDecimal", bigDecimalValue);
   8:         ...
   9:    private final Time timeValue;
  10:    private final Timestamp timestampValue = new Timestamp(4444);
  11:    private final BigDecimal bigDecimalValue = new BigDecimal("12345678.1234");
  12:         ...
  13:          utilDateValue + ">",
  14:          utilDateValue.compareTo(simple.getUtilDateValue()) == 0);

View Full Code Here

compareTo

public int compareTo(Date o)
Compares this Timestamp object to the given Date, which must be a Timestamp object. If the argument is not a Timestamp object, this method throws a ClassCastException object. (Timestamp objects are comparable only to other Timestamp objects.)
Overrides:
compareTo in interface Date
Parameters:
o - the Date to be compared, which must be a Timestamp object
Returns:
the value 0 if this Timestamp object and the given object are equal; a value less than 0 if this Timestamp object is before the given argument; and a value greater than 0 if this Timestamp object is after the given argument.
Since:
1.5
Usages and Demos :

View More Examples of compareTo(java.util.Date o)
   1: 
   2: import java.sql.Timestamp;
   3: 
   4:         ...
   5:     private boolean success;
   6:     private Timestamp timestamp;
   7: 
   8:         ...
   9:         Archive archive = (Archive)o;
  10:         return timestamp.compareTo(archive.timestamp);
  11:     }

View Full Code Here
   1: 
   2: import java.sql.Timestamp;
   3: 
   4:         ...
   5:     private String details;
   6:     private Timestamp timestamp;
   7: 
   8:         ...
   9:         Log log = (Log)o;
  10:         int diff = activity.compareTo(log.activity);
  11:         if (diff != 0)
  12:         ...
  13:             return diff;
  14:         return timestamp.compareTo(log.timestamp);

View Full Code Here
   1: import java.math.BigDecimal;
   2: import java.sql.Timestamp;
   3: import java.util.Comparator;
   4:         ...
   5:             String s = (String)cmp1;
   6:             return s.compareTo((String)cmp2) * m_multiplier;
   7:         }
   8:         ...
   9:         else if (cmp1 instanceof Timestamp && cmp2 instanceof Timestamp)
  10:         {
  11:         ...
  12:             Timestamp t = (Timestamp)cmp1;
  13:             return t.compareTo((Timestamp)cmp2) * m_multiplier;

View Full Code Here
   1: import java.util.*;
   2: import java.sql.Timestamp;
   3: import oracle.toplink.essentials.expressions.*;
   4:         ...
   5:     public int compareWriteLockValues(Object value1, Object value2) {
   6:         java.sql.Timestamp timestampValue1 = (java.sql.Timestamp)value1;
   7:         java.sql.Timestamp timestampValue2 = (java.sql.Timestamp)value2;
   8:         ...
   9:         return timestampValue1.compareTo(timestampValue2);
  10:     }

View Full Code Here
   1: import java.sql.Time;
   2: import java.sql.Timestamp;
   3: import java.util.Collection;
   4:         ...
   5:       ((HashMap) objectValue).put("time", timeValue);
   6:       ((HashMap) objectValue).put("timestamp", timestampValue);
   7:       ((HashMap) objectValue).put("bigDecimal", bigDecimalValue);
   8:         ...
   9:    private final Time timeValue;
  10:    private final Timestamp timestampValue = new Timestamp(4444);
  11:    private final BigDecimal bigDecimalValue = new BigDecimal("12345678.1234");
  12:         ...
  13:          utilDateValue + ">",
  14:          utilDateValue.compareTo(simple.getUtilDateValue()) == 0);

View Full Code Here

equals

public boolean equals(Object ts)
Tests to see if this Timestamp object is equal to the given object. This version of the method equals has been added to fix the incorrect signature of Timestamp.equals(Timestamp) and to preserve backward compatibility with existing class files. Note: This method is not symmetric with respect to the equals(Object) method in the base class.
Overrides:
equals in interface Date
Parameters:
ts - the Object value to compare with
Returns:
true if the given Object instance is equal to this Timestamp object; false otherwise
Usages and Demos :

View More Examples of equals(java.lang.Object ts)
   1: import java.sql.Statement;
   2: import java.sql.Timestamp;
   3: 
   4:         ...
   5:             {
   6:                 s.execute("CREATE TABLE DATETEST (DATEID INTEGER NOT NULL PRIMARY KEY, TESTDATE TIMESTAMP)");
   7:                 PreparedStatement ps = c.prepareStatement("INSERT INTO DATETEST (DATEID, TESTDATE) VALUES (?,?)");
   8:         ...
   9:                 Calendar cal = new GregorianCalendar(timeZoneUTC);
  10:                 Timestamp x = Timestamp.valueOf("17-02-1917 20:59:31");
  11:                 try 
  12:         ...
  13:                         Timestamp x2 = rs.getTimestamp(1, cal);
  14:                         assertTrue("Retrieved wrong value! expected: " + x + ", actual: " + x2, x.equals(x2));

View Full Code Here

equals

public boolean equals(Timestamp ts)
Tests to see if this Timestamp object is equal to the given Timestamp object.
Parameters:
ts - the Timestamp value to compare with
Returns:
true if the given Timestamp object is equal to this Timestamp object; false otherwise
Usages and Demos :

View More Examples of equals(Timestamp ts)
   1: import java.sql.Statement;
   2: import java.sql.Timestamp;
   3: 
   4:         ...
   5:             {
   6:                 s.execute("CREATE TABLE DATETEST (DATEID INTEGER NOT NULL PRIMARY KEY, TESTDATE TIMESTAMP)");
   7:                 PreparedStatement ps = c.prepareStatement("INSERT INTO DATETEST (DATEID, TESTDATE) VALUES (?,?)");
   8:         ...
   9:                 Calendar cal = new GregorianCalendar(timeZoneUTC);
  10:                 Timestamp x = Timestamp.valueOf("17-02-1917 20:59:31");
  11:                 try 
  12:         ...
  13:                         Timestamp x2 = rs.getTimestamp(1, cal);
  14:                         assertTrue("Retrieved wrong value! expected: " + x + ", actual: " + x2, x.equals(x2));

View Full Code Here

getNanos

public int getNanos()
Gets this Timestamp object's nanos value.
Returns:
this Timestamp object's fractional seconds component
See Also:
setNanos(int)
Usages and Demos :

View More Examples of getNanos()
   1: 
   2: import java.sql.Timestamp;
   3: import java.util.Date;
   4:         ...
   5:     public boolean canConvert(Class type) {
   6:         return type.equals(Timestamp.class);
   7:     }
   8:         ...
   9:         final Date date = (Date)super.fromString(str);
  10:         final Timestamp timestamp = new Timestamp(date.getTime());
  11:         timestamp.setNanos(nanos);
  12:         ...
  13:         String str = super.toString(new Date((timestamp.getTime() / 1000) * 1000));
  14:         final String nanos = String.valueOf(timestamp.getNanos());

View Full Code Here
   1: 
   2: import java.sql.Timestamp;
   3: 
   4:         ...
   5: public class TimestampCopy extends Timestamp
   6: {
   7:         ...
   8:    public TimestampCopy(
   9:       Timestamp original
  10:    )
  11:         ...
  12:       super(original.getTime());
  13:       setNanos(original.getNanos());

View Full Code Here
   1: import java.sql.SQLException;
   2: import java.sql.Timestamp;
   3: import java.sql.Types;
   4:         ...
   5: 
   6:         Timestamp ts = rs.getTimestamp(name);
   7:         if (ts!=null) {
   8:         ...
   9:             if ( Environment.jvmHasTimestampBug() ) {
  10:                 cal.setTime( new Date( ts.getTime() + ts.getNanos() / 1000000 ) );
  11:             }
  12:         ...
  13:         final Calendar cal = (Calendar) value;
  14:         st.setTimestamp( index,  new Timestamp( cal.getTime().getTime() ), cal );

View Full Code Here
   1:       faq.setAnswer(results.getString("ANSWER"));
   2:       Timestamp t = results.getTimestamp("MODIFIED");
   3:       java.util.Date d;
   4:         ...
   5:       d = new java.util.Date(t.getTime() + (t.getNanos()/1000000));
   6:       faq.setLastModified(d);
   7:         ...
   8:     updStmt.setString(2, faq.getAnswer());
   9:     Timestamp now;
  10:         ...
  11:     now = new Timestamp(faq.getLastModified().getTime());

View Full Code Here
   1: import java.sql.ResultSetMetaData;
   2: import java.sql.Timestamp;
   3: import java.sql.Types;
   4:         ...
   5:          return r.getDate(index).getTime();
   6:       case Types.TIMESTAMP:
   7:         ...
   8:          Timestamp timestamp = r.getTimestamp(index);
   9:          long time = timestamp.getTime();
  10:         ...
  11:          if (time % 1000 == 0)
  12:             time += timestamp.getNanos() / 1000000;

View Full Code Here

getTime

public long getTime()
Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this Timestamp object.
Overrides:
getTime in interface Date
Returns:
the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this date.
See Also:
setTime(long)
Usages and Demos :

View More Examples of getTime()
   1: 
   2: import java.sql.Timestamp;
   3: import java.util.Date;
   4:         ...
   5:     public boolean canConvert(Class type) {
   6:         return type.equals(Timestamp.class);
   7:     }
   8:         ...
   9:         final Date date = (Date)super.fromString(str);
  10:         final Timestamp timestamp = new Timestamp(date.getTime());
  11:         timestamp.setNanos(nanos);
  12:         ...
  13:         final Timestamp timestamp = (Timestamp)obj;
  14:         String str = super.toString(new Date((timestamp.getTime() / 1000) * 1000));

View Full Code Here
   1: 
   2: import java.sql.Timestamp;
   3: import java.util.Collections;
   4:         ...
   5:     private static Object today(List args) {
   6:         Timestamp ts = new Timestamp(System.currentTimeMillis());
   7: 
   8:         ...
   9:             if (!qv.isNil() && qv.getValue() instanceof Integer) {
  10:                 ts = new Timestamp(ts.getTime() + ((Integer) qv.getValue()).intValue() * 86400000L);
  11:             } else {

View Full Code Here
   1: import javax.jms.Session;
   2: import java.sql.Timestamp;
   3: import java.text.ParseException;
   4:         ...
   5:     public boolean canBuild(Class targetClass) {
   6:         return targetClass.equals(Timestamp.class);
   7:     }
   8:         ...
   9:             Object fieldVal) {
  10:         Timestamp realVal = (Timestamp) fieldVal;
  11:         ...
  12:         String sVal = getDateFormat().format(new Date(realVal.getTime()));

View Full Code Here
   1: import java.sql.SQLException;
   2: import java.sql.Timestamp;
   3: import java.util.Date;
   4:         ...
   5: 
   6:     private Timestamp timestamp;
   7: 
   8:         ...
   9:     public void setValue(Date date) {
  10:         timestamp = new Timestamp(date.getTime());
  11:     }
  12:         ...
  13:     public Date getValue() {
  14:         return timestamp == null ? null : new Date(timestamp.getTime());

View Full Code Here
   1: 
   2: import java.sql.Timestamp;
   3: import java.util.Properties;
   4:         ...
   5:     
   6:     public Timestamp execReplicate(Timestamp markerIn, Set<ITracker> statementTrackers, Set<ITracker> newStatementTrackers, IBocaHandler bocaHandler) throws BocaException {
   7:         ...
   8:         return new Timestamp(baseService.modelService.replicate(baseService.authenticateServiceUser(), statementTrackers, newStatementTrackers, (markerIn!=null)?markerIn.getTime():null, bocaHandler));
   9:     }

View Full Code Here

setNanos

public void setNanos(int n)
Sets this Timestamp object's nanos field to the given value.
Parameters:
n - the new fractional seconds component
Throws:
IllegalArgumentException - if the given argument is greater than 999999999 or less than 0
See Also:
getNanos()
Usages and Demos :

View More Examples of setNanos(int n)
   1: 
   2: import java.sql.Timestamp;
   3: import java.util.Date;
   4:         ...
   5:     public boolean canConvert(Class type) {
   6:         return type.equals(Timestamp.class);
   7:     }
   8:         ...
   9:         final Date date = (Date)super.fromString(str);
  10:         final Timestamp timestamp = new Timestamp(date.getTime());
  11:         ...
  12:         timestamp.setNanos(nanos);

View Full Code Here
   1: import java.sql.SQLException;
   2: import java.sql.Timestamp;
   3: import java.sql.Types;
   4:         ...
   5:     public void set(PreparedStatement st, Object value, int index) throws SQLException {
   6:         Timestamp ts;
   7:         ...
   8:         if (value instanceof Timestamp) {
   9:             ts = (Timestamp) value;
  10:         ...
  11:             Timestamp ts = new Timestamp( orig.getTime() );
  12:             ts.setNanos( orig.getNanos() );

View Full Code Here
   1: import java.sql.SQLException;
   2: import java.sql.Timestamp;
   3: import java.sql.Types;
   4:         ...
   5:     public void set(PreparedStatement st, Object value, int index) throws SQLException {
   6:         Timestamp ts;
   7:         ...
   8:         if (value instanceof Timestamp) {
   9:             ts = (Timestamp) value;
  10:         ...
  11:             Timestamp ts = new Timestamp( orig.getTime() );
  12:             ts.setNanos( orig.getNanos() );

View Full Code Here
   1: 
   2: import java.sql.Timestamp;
   3: 
   4:         ...
   5: 
   6:         Timestamp ts1 = new Timestamp(currentTime);
   7:         String xmlString = xs.toXML(ts1);
   8:         ...
   9:         Timestamp ts1 = new Timestamp(System.currentTimeMillis());
  10:         ts1.setNanos(987654321);
  11:         String xmlString = xs.toXML(ts1);

View Full Code Here
   1: import java.sql.SQLException;
   2: import java.sql.Timestamp;
   3: import java.sql.Types;
   4:         ...
   5:     public void set(PreparedStatement st, Object value, int index) throws SQLException {
   6:         Timestamp ts;
   7:         ...
   8:         if (value instanceof Timestamp) {
   9:             ts = (Timestamp) value;
  10:         ...
  11:             Timestamp ts = new Timestamp( orig.getTime() );
  12:             ts.setNanos( orig.getNanos() );

View Full Code Here

setTime

public void setTime(long time)
Sets this Timestamp object to represent a point in time that is time milliseconds after January 1, 1970 00:00:00 GMT.
Overrides:
setTime in interface Date
Parameters:
time - the number of milliseconds.
See Also:
getTime(), Timestamp(long time), for more information
Usages and Demos :

View More Examples of setTime(long time)
   1: import java.io.IOException;
   2: import java.sql.Timestamp;
   3: import java.util.ArrayList;
   4:         ...
   5:                     newEventHashMap.put("Moderator", Integer.toString(oldEvent.getModeratorid()));
   6:                     Timestamp startTimestamp = (Timestamp)oldEvent.getStartdate();
   7:                     Timestamp endTimestamp = (Timestamp)oldEvent.getEnddate();
   8:         ...
   9:                     tempCalendar.add(Calendar.YEAR, 1900);
  10:                     startTimestamp.setTime(tempCalendar.getTimeInMillis());
  11: 
  12:         ...
  13:                     tempCalendar.add(Calendar.YEAR, 1900);
  14:                     endTimestamp.setTime(tempCalendar.getTimeInMillis());

View Full Code Here
   1: import java.util.Date;
   2: import java.sql.Timestamp;
   3: 
   4:         ...
   5: 
   6:     private static final String _xmlName = "sql-timestamp";
   7: 
   8:         ...
   9:                             
  10:                         if (java.sql.Timestamp.class == object.getClass()) {
  11:                             Class type = value.getClass();
  12:         ...
  13:                                  Timestamp temp = (Timestamp)value;
  14:                                  target.setTime(temp.getTime());

View Full Code Here
   1:       dateValue = new java.sql.Date(new java.util.Date().getTime());
   2:       dateValue.setTime(tmpDate.getTime());
   3:       return dateValue;
   4:         ...
   5: 
   6:   public static java.sql.Timestamp parseTimestampString(String tmp) {
   7:         ...
   8:     java.sql.Timestamp timestampValue = null;
   9:     try {
  10:         ...
  11:       java.util.Date tmpDate = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.LONG).parse(tmp);
  12:       timestampValue = new java.sql.Timestamp(new java.util.Date().getTime());

View Full Code Here
   1:       dateValue = new java.sql.Date(new java.util.Date().getTime());
   2:       dateValue.setTime(tmpDate.getTime());
   3:       return dateValue;
   4:         ...
   5: 
   6:   public static java.sql.Timestamp parseTimestamp(String tmp) {
   7:     return parseTimestamp(tmp, Locale.getDefault());
   8:         ...
   9: 
  10:   public static java.sql.Timestamp parseTimestamp(String tmp, Locale locale) {
  11:         ...
  12:     java.sql.Timestamp timestampValue = null;

View Full Code Here
   1: import java.rmi.RemoteException;
   2: import java.sql.Timestamp;
   3: import java.math.BigDecimal;
   4:         ...
   5:     String s;
   6:     Timestamp currentTime;
   7:         ...
   8:     currentTime = new Timestamp(System.currentTimeMillis());
   9:     s = EchoUtil.getDateString(currentTime);
  10:         ...
  11:     Date date = new Date(System.currentTimeMillis());
  12:     currentTime.setTime(date);

View Full Code Here

toString

public String toString()
Formats a timestamp in JDBC timestamp escape format. yyyy-mm-dd hh:mm:ss.fffffffff, where ffffffffff indicates nanoseconds.

NOTE: To specify a timestamp for the class java.text.SimpleDateFormat, use "yyyy.MM.dd" rather than "yyyy-mm-dd". In the context of java.text.SimpleDateFormat, "mm" indicates minutes rather than the month. Note that java.text.SimpleDateFormat does not allow for the nanoseconds component of a Timestamp object. For Example:


 Format Pattern				Result
 --------------				------
 "yyyy.MM.dd G 'at' hh:mm:ss z"	-->	2002.07.10 AD at 15:08:56 PDT

 
Overrides:
toString in interface Date
Returns:
a String object in yyyy-mm-dd hh:mm:ss.fffffffff format
Usages and Demos :

View More Examples of toString()
   1: import java.sql.SQLException;
   2: import java.sql.Timestamp;
   3: import java.util.Date;
   4:         ...
   5: 
   6:     private Timestamp timestamp;
   7: 
   8:         ...
   9:     public String toString() {
  10:         return timestamp == null ? "" : timestamp.toString();
  11:     }

View Full Code Here
   1: import java.sql.SQLException;
   2: import java.sql.Timestamp;
   3: import java.sql.Types;
   4:         ...
   5:         stmt.append(" MODE");
   6:         return stmt.toString();
   7:     }
   8:         ...
   9: 
  10:     public String getTimestampString(Timestamp timestamp) {
  11:         ...
  12:         return "'" + timestamp.toString() + "'";

View Full Code Here
   1: import java.sql.SQLException;
   2: import java.sql.Timestamp;
   3: import java.sql.Types;
   4:         ...
   5:             stmt.append("FOR UPDATE");
   6:         return stmt.toString();
   7:     }
   8:         ...
   9: 
  10:     public String getTimestampString(Timestamp timestamp) {
  11:         ...
  12:         return "TIMESTAMP '" + timestamp.toString() + "'";

View Full Code Here
   1: 
   2: import java.sql.Timestamp;
   3: 
   4:         ...
   5:         else
   6:             setKey(article.toString());
   7:     }
   8:         ...
   9: 
  10:     private Timestamp contributed = null;
  11: 
  12:         ...
  13: 
  14:     public Timestamp getContributed() {

View Full Code Here
   1: {
   2:     private Timestamp   m_DateValue;
   3:     private int         m_C_Currency_ID;
   4:         ...
   5:             else if (name.equals("DateValue"))
   6:                 m_DateValue = (Timestamp)para[i].getParameter();
   7:             else if (name.equals("M_Warehouse_ID"))
   8:         ...
   9:         if (m_DateValue == null)
  10:             m_DateValue = new Timestamp (System.currentTimeMillis());
  11: 
  12:         ...
  13:         sql.append(m_M_Warehouse_ID);
  14:         int no = DB.executeUpdate(sql.toString(), get_TrxName());

View Full Code Here

valueOf

public static Timestamp valueOf(String s)
Converts a String object in JDBC timestamp escape format to a Timestamp value.
Parameters:
s - timestamp in format yyyy-mm-dd hh:mm:ss.fffffffff
Returns:
corresponding Timestamp value
Throws:
IllegalArgumentException - if the given argument does not have the format yyyy-mm-dd hh:mm:ss.fffffffff
Usages and Demos :

View More Examples of valueOf(String s)
   1: 
   2: import java.sql.Timestamp;
   3: 
   4:         ...
   5:     public boolean canConvert(Class type) {
   6:         return type.equals(Timestamp.class);
   7:     }
   8:         ...
   9:     public Object fromString(String str) {
  10:         return Timestamp.valueOf(str);
  11:     }

View Full Code Here
   1: import java.sql.Time;
   2: import java.sql.Timestamp;
   3: import java.util.Hashtable;
   4:         ...
   5:             if( val==null || val.length()==0 ) return new Byte((byte)0);
   6:             return Byte.valueOf(val);
   7:         } else
   8:         ...
   9:             if( val==null || val.length()==0 ) return new Double(0);
  10:             return Double.valueOf(val);
  11:         } else
  12:         ...
  13:             if( val==null || val.length()==0 ) return new Float(0);
  14:             return Float.valueOf(val);

View Full Code Here
   1:       try {
   2:         return java.sql.Date.valueOf(tmp);
   3:       } catch (Exception e2) {
   4:         ...
   5: 
   6:   public static java.sql.Timestamp parseTimestampString(String tmp) {
   7:         ...
   8:     java.sql.Timestamp timestampValue = null;
   9:     try {
  10:         ...
  11:       java.util.Date tmpDate = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.LONG).parse(tmp);
  12:       timestampValue = new java.sql.Timestamp(new java.util.Date().getTime());

View Full Code Here
   1: 
   2: import java.sql.Timestamp;
   3: import java.sql.Date;
   4:         ...
   5: 
   6:         return Date.valueOf(getString().trim());
   7:     }
   8:         ...
   9: 
  10:         return Time.valueOf(getString().trim());
  11:     }
  12:         ...
  13:     public Timestamp getTimestamp(Calendar cal) throws SQLException {

View Full Code Here
   1: 
   2: import java.sql.Timestamp;
   3: 
   4:         ...
   5:             int digit = Integer.parseInt(
   6:                 String.valueOf(number.charAt(count)));
   7:                 digit *= 2;
   8:         ...
   9: 
  10:     public static Timestamp NULL_TIMESTAMP = new Timestamp(NULL_TIME);
  11: 
  12:         ...
  13:         else try {
  14:             return Timestamp.valueOf(string);

View Full Code Here