Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Apache Druid Joda To Regexp

From Leeroopedia
Revision as of 14:14, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Apache_Druid_Joda_To_Regexp.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Knowledge Sources
Domains Web_Console, Date_Time_Parsing
Last Updated 2026-02-10 10:00 GMT

Overview

Converts Joda-Time format strings into equivalent JavaScript regular expressions for date pattern validation.

Description

This module provides a lookup table mapping Joda-Time format fragments (such as YYYY, MM, dd, HH, mm, ss, SSS) to their corresponding regular expression patterns. The single exported function `jodaFormatToRegExp` replaces each recognized Joda fragment in a format string with its regex equivalent and returns a case-insensitive RegExp anchored with ^ and $. This enables validation of date strings against Joda-Time formats commonly used in Druid ingestion specifications.

Usage

Used during data ingestion configuration to validate that sample date strings match the user-specified Joda-Time format pattern, helping detect format mismatches before ingestion begins.

Code Reference

Source Location

Signature

export function jodaFormatToRegExp(jodaFormat: string): RegExp;

Import

import { jodaFormatToRegExp } from './utils/joda-to-regexp';

I/O Contract

Inputs

Name Type Required Description
jodaFormat string Yes A Joda-Time format string (e.g., "yyyy-MM-dd'T'HH:mm:ss.SSS")

Outputs

Name Type Description
(return) RegExp A case-insensitive RegExp anchored with ^ and $ that matches date strings conforming to the given Joda format

Usage Examples

Validate a date string against a Joda format

import { jodaFormatToRegExp } from './utils/joda-to-regexp';

const regex = jodaFormatToRegExp('yyyy-MM-dd');
regex.test('2024-01-15'); // true
regex.test('24-1-5');     // false

Match a full datetime format

import { jodaFormatToRegExp } from './utils/joda-to-regexp';

const regex = jodaFormatToRegExp('yyyy-MM-dd HH:mm:ss');
regex.test('2024-01-15 09:30:00'); // true

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment