Sha256: 2bf5cf2100571bdd8c23c84889e03717e39abea902fa89390ddf4b2e4b9b1ddd
Contents?: true
Size: 1.9 KB
Versions: 9
Compression:
Stored size: 1.9 KB
Contents
package org.embulk.output.oracle; import java.sql.Timestamp; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import org.junit.Test; import static org.junit.Assert.assertEquals; public class TimestampFormatTest { @Test public void test() throws ParseException { Date date = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").parse("2015/03/04 17:08:09"); Timestamp t = new Timestamp(date.getTime()); { TimestampFormat format = new TimestampFormat("yyyy-MM-dd HH:mm:ss", 9); assertEquals("2015-03-04 17:08:09.000000000", format.format(t)); } { TimestampFormat format = new TimestampFormat("yyyy-MM-dd HH:mm:ss", 0); assertEquals("2015-03-04 17:08:09", format.format(t)); } { TimestampFormat format = new TimestampFormat("yyyy-MM-dd HH:mm:ss", 1); assertEquals("2015-03-04 17:08:09.0", format.format(t)); } t.setNanos(1234567); { TimestampFormat format = new TimestampFormat("yyyy-MM-dd HH:mm:ss", 9); assertEquals("2015-03-04 17:08:09.001234567", format.format(t)); } { TimestampFormat format = new TimestampFormat("yyyy-MM-dd HH:mm:ss", 2); assertEquals("2015-03-04 17:08:09.00", format.format(t)); } { TimestampFormat format = new TimestampFormat("yyyy-MM-dd HH:mm:ss", 3); assertEquals("2015-03-04 17:08:09.001", format.format(t)); } t.setNanos(123456789); { TimestampFormat format = new TimestampFormat("yyyy-MM-dd HH:mm:ss", 9); assertEquals("2015-03-04 17:08:09.123456789", format.format(t)); } { TimestampFormat format = new TimestampFormat("yyyy-MM-dd HH:mm:ss", 1); assertEquals("2015-03-04 17:08:09.1", format.format(t)); } } }
Version data entries
9 entries across 9 versions & 1 rubygems