Sha256: 9b39c8d11d38a70a1f9c92aa7832aaaa7969be5f14333a8a7764368468317367
Contents?: true
Size: 1.06 KB
Versions: 3
Compression:
Stored size: 1.06 KB
Contents
package org.embulk.parser.jsonl.cast; import org.embulk.spi.DataException; import org.embulk.spi.time.Timestamp; public class DoubleCast { private DoubleCast() {} private static String buildErrorMessage(String as, double value) { return String.format("cannot cast double to %s: \"%s\"", as, value); } public static boolean asBoolean(double value) throws DataException { throw new DataException(buildErrorMessage("boolean", value)); } public static long asLong(double value) throws DataException { return (long) value; } public static double asDouble(double value) throws DataException { return value; } public static String asString(double value) throws DataException { return String.valueOf(value); } public static Timestamp asTimestamp(double value) throws DataException { long epochSecond = (long) value; long nanoAdjustMent = (long) ((value - epochSecond) * 1000000000); return Timestamp.ofEpochSecond(epochSecond, nanoAdjustMent); } }
Version data entries
3 entries across 3 versions & 2 rubygems