Sha256: 2a185a7de7d6aa651dddae8dbba498f9ca4a60f8305152864b9e0dbf143a2c2c
Contents?: true
Size: 1.07 KB
Versions: 7
Compression:
Stored size: 1.07 KB
Contents
package org.embulk.parser.jsonpath.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
7 entries across 7 versions & 1 rubygems