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;
}
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
}
}
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);
}
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);
}
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);
}
Aggregations