Search in sources :

Example 66 with Timestamp

use of java.sql.Timestamp in project groovy by apache.

the class DateGroovyMethods method plus.

/**
     * Add number of days to this Timestamp and returns the new Timestamp object.
     *
     * @param self a Timestamp
     * @param days the number of days to increase
     * @return the new Timestamp
     */
public static Timestamp plus(Timestamp self, int days) {
    Calendar calendar = (Calendar) Calendar.getInstance().clone();
    calendar.setTime(self);
    calendar.add(Calendar.DAY_OF_YEAR, days);
    Timestamp ts = new Timestamp(calendar.getTime().getTime());
    ts.setNanos(self.getNanos());
    return ts;
}
Also used : Calendar(java.util.Calendar) Timestamp(java.sql.Timestamp)

Example 67 with Timestamp

use of java.sql.Timestamp in project camel by apache.

the class StaticFallbackConverterTest method testStaticFallbackMandatoryFailed.

public void testStaticFallbackMandatoryFailed() throws Exception {
    Exchange exchange = new DefaultExchange(context);
    try {
        context.getTypeConverter().mandatoryConvertTo(Date.class, exchange, new Timestamp(0));
        fail("Should have thrown an exception");
    } catch (NoTypeConversionAvailableException e) {
    // expected
    }
}
Also used : DefaultExchange(org.apache.camel.impl.DefaultExchange) Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) NoTypeConversionAvailableException(org.apache.camel.NoTypeConversionAvailableException) Timestamp(java.sql.Timestamp)

Example 68 with Timestamp

use of java.sql.Timestamp in project camel by apache.

the class InstanceFallbackConverterTest method testInstanceFallbackFailed.

public void testInstanceFallbackFailed() throws Exception {
    Exchange exchange = new DefaultExchange(context);
    Date out = context.getTypeConverter().convertTo(Date.class, exchange, new Timestamp(0));
    assertNull(out);
}
Also used : DefaultExchange(org.apache.camel.impl.DefaultExchange) Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) Timestamp(java.sql.Timestamp) Date(java.sql.Date)

Example 69 with Timestamp

use of java.sql.Timestamp in project camel by apache.

the class SQLConverterTest method testTimestamp.

public void testTimestamp() {
    long value = System.currentTimeMillis();
    Timestamp ts = context.getTypeConverter().convertTo(Timestamp.class, value);
    Timestamp expected = new Timestamp(value);
    assertEquals(expected, ts);
}
Also used : Timestamp(java.sql.Timestamp)

Example 70 with Timestamp

use of java.sql.Timestamp in project camel by apache.

the class StaticFallbackConverterTest method testStaticFallbackFailed.

public void testStaticFallbackFailed() throws Exception {
    Exchange exchange = new DefaultExchange(context);
    Date out = context.getTypeConverter().convertTo(Date.class, exchange, new Timestamp(0));
    assertNull(out);
}
Also used : DefaultExchange(org.apache.camel.impl.DefaultExchange) Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) Timestamp(java.sql.Timestamp) Date(java.sql.Date)

Aggregations

Timestamp (java.sql.Timestamp)1539 PreparedStatement (java.sql.PreparedStatement)265 Test (org.junit.Test)245 SQLException (java.sql.SQLException)236 ResultSet (java.sql.ResultSet)209 BigDecimal (java.math.BigDecimal)204 Date (java.util.Date)165 Date (java.sql.Date)122 Connection (java.sql.Connection)117 ArrayList (java.util.ArrayList)109 Calendar (java.util.Calendar)76 Test (org.testng.annotations.Test)71 GregorianCalendar (java.util.GregorianCalendar)68 Time (java.sql.Time)65 SimpleDateFormat (java.text.SimpleDateFormat)62 Change (com.google.gerrit.reviewdb.client.Change)59 IOException (java.io.IOException)51 BaseTest (util.BaseTest)49 PatchSet (com.google.gerrit.reviewdb.client.PatchSet)45 Properties (java.util.Properties)41