{"record":{"id":"22517ce6a7eab75d","repo":"apache/cassandra","slug":"unable-to-make-long-for-date-from-s","errorCode":null,"errorMessage":"Unable to make long (for date) from: '%s'","messagePattern":"Unable to make long \\(for date\\) from: '(.+?)'","errorType":"validation","errorClass":"MarshalException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/serializers/TimestampSerializer.java","lineNumber":162,"sourceCode":"    {\n        return value == null ? ByteBufferUtil.EMPTY_BYTE_BUFFER : ByteBufferUtil.bytes(value.getTime());\n    }\n\n    public static long dateStringToTimestamp(String source) throws MarshalException\n    {\n        if (source.equalsIgnoreCase(\"now\"))\n            return currentTimeMillis();\n\n        // Milliseconds since epoch?\n        if (timestampPattern.matcher(source).matches())\n        {\n            try\n            {\n                return Long.parseLong(source);\n            }\n            catch (NumberFormatException e)\n            {\n                throw new MarshalException(String.format(\"Unable to make long (for date) from: '%s'\", source), e);\n            }\n        }\n\n        for (DateTimeFormatter fmt: dateFormatters)\n        {\n            try\n            {\n                return ZonedDateTime.parse(source, fmt).toInstant().toEpochMilli();\n            }\n            catch (DateTimeParseException e)\n            {\n                continue;\n            }\n        }\n        throw new MarshalException(String.format(\"Unable to parse a date/time from '%s'\", source));\n    }\n\n    public static Format getJsonDateFormatter()","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/serializers/TimestampSerializer.java#L144-L180","documentation":"TimestampSerializer.dateStringToTimestamp, when the input does not look like a date string, attempts to parse it as a plain long (epoch milliseconds). This error means the string is numeric-looking (starts with a digit or +/-) but not a valid long, so it cannot be interpreted as an epoch-millis timestamp.","triggerScenarios":"Passing numeric strings that overflow long (e.g. 20+ digit numbers), decimals like '1694000000.5', or numbers with separators/underscores into a timestamp column; also strings starting with digits but containing letters.","commonSituations":"High-precision epoch values from other systems (nanos/micros since epoch) overflowing the millis long; timestamps with fractional seconds passed as strings; locale-formatted numbers with thousand separators.","solutions":["Pass a plain integer string of epoch milliseconds, e.g. '1286598400000'","Convert nanos/micros to millis: String.valueOf(nanos / 1_000_000)","Or pass an ISO-8601 date/time string instead, e.g. '2015-05-03 13:30:54.234' — the formatter loop will parse it","Trim the string; remove fractional part or rounding to whole millis"],"exampleFix":"// before\nsession.execute(\"INSERT INTO t (ts) VALUES (?)\", \"1694000000.5\");\n// after\nsession.execute(\"INSERT INTO t (ts) VALUES (?)\", \"1694000000500\");","handlingStrategy":"validation","validationCode":"if (input.matches(\"^[+-]?\\\\d+$\")) {\n  try { Long.parseLong(input.trim()); } catch (NumberFormatException e) { throw new IllegalArgumentException(\"numeric timestamp overflows long: \" + input); }\n}","typeGuard":"boolean isParsableEpochMillis(String s) {\n  try { long v = Long.parseLong(s.trim()); return true; } catch (NumberFormatException e) { return false; }\n}","tryCatchPattern":"try {\n  Date ts = TimestampSerializer.dateStringToTimestamp(input);\n} catch (MarshalException e) {\n  throw new BadRequestException(\"timestamp must be epoch-millis long or ISO-8601 string\");\n}","preventionTips":["Convert nanosecond/microsecond epochs to milliseconds before sending","Reject fractional-second numeric strings; round to whole millis","Trim whitespace and locale separators from numeric input","Prefer ISO-8601 strings for readability and safety"],"tags":["cassandra","serialization","timestamp","number-format"],"backgroundTag":"invalid-argument-format","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}