Java 8 Timestamp - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Timestamp class.

This code example shows how to use the following methods:
    case Types.DATE:
      return new java.sql.Date(val);
    case Types.TIME:
      return new java.sql.Time(val);
    case Types.TIMESTAMP:
      return new java.sql.Timestamp(val);
    default: // Shouldn't ever hit this case. 
      return null; 
    } 
  } 
 
  /** 
   * Given a Date 'd', format it as a string for use in a SQL date 
   * comparison operation. 
   * @param d the date to format. 
   * @return the string representing this date in SQL with any appropriate 
   * quotation characters, etc. 
   */ 
  protected String dateToString(Date d) {
    return "'" + d.toString() + "'";
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getTime
	@Test 
    public void testTimestampToXmlGregorianCalendarConverter() { 
        MapperFactory factory = MappingUtil.getMapperFactory();
        MapperFacade mapper = factory.getMapperFacade();
         
        Timestamp now = new Timestamp(System.currentTimeMillis());
        XMLGregorianCalendar xml = mapper.map(now, XMLGregorianCalendar.class);
         
        Assert.assertEquals(now.getTime(), xml.toGregorianCalendar().getTimeInMillis());
         
        Timestamp reverse = mapper.map(xml, Timestamp.class);
        Assert.assertEquals(now, reverse);
    } 
     
    @Test 
    public void testTimestampToDateConverter() { 
        MapperFactory factory = MappingUtil.getMapperFactory();
        MapperFacade mapper = factory.getMapperFacade();
         
        Timestamp now = new Timestamp(System.currentTimeMillis());
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
 
public class HiveValueReader extends WritableValueReader { 
 
    @Override 
    protected Object date(String value) { 
        return new TimestampWritable(new Timestamp(DatatypeConverter.parseDateTime(value).getTimeInMillis())); 
    } 
 
    @Override 
    protected Class<? extends Writable> dateType() { 
        return TimestampWritable.class; 
    } 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
 
    private Timestamp timestamp(final Date date) {
        if (date == null) {
            return null; 
        } 
        return new Timestamp(date.getTime());
    } 
 
 
    public InjectedValue<ManagedReferenceFactory> getDataSourceInjectedValue() { 
        return dataSourceInjectedValue;
    } 
 
    public InjectedValue<ModuleLoader> getModuleLoader() { 
        return moduleLoader;
    } 
 
    private static void safeClose(final Closeable resource) {
        try { 
            if (resource != null) {
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getTime
    protected DateTime extractByName(final ResultSet r, final String name) throws SQLException {
        final Timestamp timestamp = r.getTimestamp(name);
        if (timestamp == null) {
            return null; 
        } 
        return new DateTime(timestamp.getTime());
    } 
 
    @Override 
    protected DateTime extractByIndex(final ResultSet r, final int index) throws SQLException {
        final Timestamp timestamp = r.getTimestamp(index);
        if (timestamp == null) {
            return null; 
        } 
        return new DateTime(timestamp.getTime());
    } 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
package org.nutz.castor.castor; 
 
import java.sql.Timestamp;
 
import org.nutz.castor.Castor; 
 
public class Number2Timestamp extends Castor<Number, Timestamp> {
 
    @Override 
    public Timestamp cast(Number src, Class<?> toType, String... args) {
        return new Timestamp(src.longValue());
    } 
 
} 

7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getTime, toString
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
     */ 
    @Test(expected=MifosRuntimeException.class) 
    public void testSaveConstraintVoilation() throws Exception { 
        Short personnelId = new Short("1");
        PersonnelBO personnelBO = TestObjectFactory.getPersonnel(personnelId);
        Timestamp timeStamp = new Timestamp(123134554L);
        String fileName = "testFile.xls";
        ImportedFilesEntity expected = new ImportedFilesEntity(fileName, timeStamp, personnelBO, null, false, false);
 
        StaticHibernateUtil.startTransaction(); 
        importedFilesDao.saveImportedFile(expected);
        StaticHibernateUtil.flushSession(); 
 
        ImportedFilesEntity shouldViolateConstraint = new ImportedFilesEntity(fileName, timeStamp, personnelBO, null, false, false);
        importedFilesDao.saveImportedFile(shouldViolateConstraint);
        StaticHibernateUtil.flushSession(); 
    } 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getNanos
			return NSComparator.OrderedDescending; 
	} 
	 
	@Override 
  public boolean equals(Timestamp ts) {
	  if (getNanos() == ts.getNanos())
	      return true; 
	  return false; 
	} 
 
	@Override 
  public boolean equals(Object ts) {
	  if (ts instanceof Timestamp) {
	    return this.equals((Timestamp)ts);
	  } 
	  return super.equals(ts);
	} 
	 
	@Override 
	public int getNanos() { 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
    	String liquibaseSchema = database.getLiquibaseSchemaName();
        String liquibaseCatalog = database.getLiquibaseCatalogName();
 
        UpdateStatement updateStatement = new UpdateStatement(liquibaseCatalog, liquibaseSchema, database.getDatabaseChangeLogLockTableName());
        updateStatement.addNewColumnValue("LOCKED", true);
        updateStatement.addNewColumnValue("LOCKGRANTED", new Timestamp(new java.util.Date().getTime()));
        updateStatement.addNewColumnValue("LOCKEDBY", hostname + hostDescription + " (" + hostaddress + ")");
        updateStatement.setWhereClause(database.escapeColumnName(liquibaseCatalog, liquibaseSchema, database.getDatabaseChangeLogTableName(), "ID") + " = 1 AND " + database.escapeColumnName(liquibaseCatalog, liquibaseSchema, database.getDatabaseChangeLogTableName(), "LOCKED") + " = "+ DataTypeFactory.getInstance().fromDescription("boolean", database).objectToSql(false, database));
 
        return SqlGeneratorFactory.getInstance().generateSql(updateStatement, database);
 
    } 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Java 8 Timestamp Questions & Answers:

See Code Examples for Java 8 Timestamp Methods: