Java Code Examples for org.embulk.spi.time.Timestamp#ofEpochSecond()
The following examples show how to use
org.embulk.spi.time.Timestamp#ofEpochSecond() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestStringCast.java From embulk-parser-jsonl with MIT License | 5 votes |
@Test public void asTimestamp() { Timestamp expected = Timestamp.ofEpochSecond(1463084053, 123456000); TimestampParser parser = new TimestampParser(jruby, "%Y-%m-%d %H:%M:%S.%N", DateTimeZone.UTC); assertEquals(expected, StringCast.asTimestamp("2016-05-12 20:14:13.123456", parser)); try { StringCast.asTimestamp("foo", parser); fail(); } catch (Throwable t) { assertTrue(t instanceof DataException); } }
Example 2
Source File: LongCast.java From embulk-parser-jsonl with MIT License | 4 votes |
public static Timestamp asTimestamp(long value) throws DataException { return Timestamp.ofEpochSecond(value); }
Example 3
Source File: DoubleCast.java From embulk-parser-jsonl with MIT License | 4 votes |
public static Timestamp asTimestamp(double value) throws DataException { long epochSecond = (long) value; long nanoAdjustMent = (long) ((value - epochSecond) * 1000000000); return Timestamp.ofEpochSecond(epochSecond, nanoAdjustMent); }
Example 4
Source File: TestLongCast.java From embulk-parser-jsonl with MIT License | 4 votes |
@Test public void asTimestamp() { Timestamp expected = Timestamp.ofEpochSecond(1); assertEquals(expected, LongCast.asTimestamp(1)); }
Example 5
Source File: TestDoubleCast.java From embulk-parser-jsonl with MIT License | 4 votes |
@Test public void asTimestamp() { Timestamp expected = Timestamp.ofEpochSecond(1, 500000000); assertEquals(expected, DoubleCast.asTimestamp(1.5)); }
Example 6
Source File: TestColumnCaster.java From embulk-parser-jsonl with MIT License | 4 votes |
@Test public void asTimestampFromFloat() { Timestamp expected = Timestamp.ofEpochSecond(1463084053, 500000000); assertEquals(expected, ColumnCaster.asTimestamp(ValueFactory.newFloat(1463084053.5), parser)); }
Example 7
Source File: TestColumnCaster.java From embulk-parser-jsonl with MIT License | 4 votes |
@Test public void asTimestampFromString() { Timestamp expected = Timestamp.ofEpochSecond(1463084053, 500000000); assertEquals(expected, ColumnCaster.asTimestamp(ValueFactory.newString("2016-05-12 20:14:13.5"), parser)); }