{"id":37029936,"url":"https://github.com/sisyphsu/dateparser","last_synced_at":"2026-01-14T03:37:31.816Z","repository":{"id":42634700,"uuid":"207962898","full_name":"sisyphsu/dateparser","owner":"sisyphsu","description":"dateparser is a smart and high-performance date parser library, it supports hundreds of different formats, nearly all format that we may used. And this is also a showcase for \"retree\" algorithm.","archived":false,"fork":false,"pushed_at":"2024-04-15T19:17:07.000Z","size":85,"stargazers_count":98,"open_issues_count":13,"forks_count":25,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-07-21T08:54:09.136Z","etag":null,"topics":["date","dateformat","dateformatter","dateparser"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sisyphsu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-09-12T04:12:15.000Z","updated_at":"2025-06-15T05:08:39.000Z","dependencies_parsed_at":"2023-02-09T03:16:14.005Z","dependency_job_id":null,"html_url":"https://github.com/sisyphsu/dateparser","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sisyphsu/dateparser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sisyphsu%2Fdateparser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sisyphsu%2Fdateparser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sisyphsu%2Fdateparser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sisyphsu%2Fdateparser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sisyphsu","download_url":"https://codeload.github.com/sisyphsu/dateparser/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sisyphsu%2Fdateparser/sbom","scorecard":{"id":827966,"data":{"date":"2025-08-11","repo":{"name":"github.com/sisyphsu/dateparser","commit":"d670a3f7a0c71a19a5c518480729c3f2932373ee"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.2,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":1,"reason":"Found 4/26 approved changesets -- score normalized to 1","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 8 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-23T16:59:20.650Z","repository_id":42634700,"created_at":"2025-08-23T16:59:20.650Z","updated_at":"2025-08-23T16:59:20.650Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28408850,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T01:52:23.358Z","status":"online","status_checked_at":"2026-01-14T02:00:06.678Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["date","dateformat","dateformatter","dateparser"],"created_at":"2026-01-14T03:37:31.091Z","updated_at":"2026-01-14T03:37:31.767Z","avatar_url":"https://github.com/sisyphsu.png","language":"Java","readme":"# dateparser\n \n[![Travis CI](https://travis-ci.org/sisyphsu/dateparser.svg?branch=master)](https://travis-ci.org/sisyphsu/dateparser)\n[![codecov](https://codecov.io/gh/sisyphsu/dateparser/branch/master/graph/badge.svg)](https://codecov.io/gh/sisyphsu/dateparser)\n\n# Introduce\n\n`dateparser` is a smart and high-performance datetime parser library, it supports hundreds of different patterns. \n\nFor better performance and flexibility, \n`dateparser` doesn't use `SimpleDateFormat` or `DateTimeFormatter`, \nbut uses [`retree`](https://github.com/sisyphsu/retree-java) to parse the specified `String` into several matched parts, \nand convert different parts to be different properties like `year`, `month`, `day`, `hour`, `minute`, `second`, `zone` etc.\n\n`dateparser` has lots of predefined regular expressions as rules, like:\n + `(?\u003cweek\u003e%s)\\W*` to match `Monday` as **week**\n + ` ?(?\u003cyear\u003e\\d{4})$` to match `2019` as **year**\n + `^(?\u003cyear\u003e\\d{4})(?\u003cmonth\u003e\\d{2})$` to match `201909` as **year** and **month**\n + ` ?(?\u003chour\u003e\\d{1,2}) o’clock\\W*` to match `12 o’clock` as **hour**\n + More rules in [`DateParserBuilder.java`](https://github.com/sisyphsu/dateparser/blob/master/src/main/java/com/github/sisyphsu/dateparser/DateParserBuilder.java)\n\nWith so many regular expressions, if use `java.util.regex.Pattern` to match them one by one, \nthe performance would be a disaster.\nSo I choice to use `retree`, `retree` could merge lots of regular expressions as one, \nin my opinion, it is more like a tree, which could execute matching quickly and concurrently. \n\nYou can also customize your own parser, by add new rules.\n\n# Install\n\nAdd maven dependency: \n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.github.sisyphsu\u003c/groupId\u003e\n  \u003cartifactId\u003edateparser\u003c/artifactId\u003e\n  \u003cversion\u003e1.0.11\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n# Basic Usage\n\nParse `String` into `Date`, `Calendar`, `LocalDateTime`, `OffsetDateTime`:\n\n```java\nDate date = DateParserUtils.parseDate(\"Mon Jan 02 15:04:05 -0700 2006\");\n// Tue Jan 03 06:04:05 CST 2006\nCalendar calendar = DateParserUtils.parseCalendar(\"Fri Jul 03 2015 18:04:07 GMT+0100 (GMT Daylight Time)\");\n// 2015-07-03T17:04:07Z\nLocalDateTime dateTime = DateParserUtils.parseDateTime(\"2019-09-20 10:20:30.12345678 +0200\");\n// 2019-09-20T16:20:30.123456780\nOffsetDateTime offsetDateTime = DateParserUtils.parseOffsetDateTime(\"2015-09-30 18:48:56.35272715 +0000 UTC\");\n// 2015-09-30T18:48:56.352727150Z\n```\n\nPlease notice the `TimeZone` and `ZoneOffset` like `-0700`, it could affect `time`.\n\n# Create new DateParser\n\nBecause `DateParser` isn't thread safe, and the `parse` operation is quite fast(about 1us),\nso `DateParserUtils` maintains one parser as default, and wrap it with `synchronized`. \n\nIf you want to use it concurrently, you should create new parser like this:\n\n```java\nDateParser parser = DateParser.newBuilder().build();\nDate date = parser.parseDate(\"Mon Jan 02 15:04:05 -0700 2006\");\n// Tue Jan 03 06:04:05 CST 2006\n``` \n\nThe `DateParser`'s instance is a little heavy, you should try to reuse it.\n\n# Prefer `MM/dd` or `dd/MM`\n\nFor most cases, `dateparser` could recognize which part is **month** and which part is **day**.\n\nBut for `MM/dd/yy` and `dd/MM/yy`, it would be confused, \nbecause most of countries use `dd/MM/yy`, but little of countries use `MM/dd/yy`, which is mainly the USA.\n\nSo `dateparser` will use `dd/MM` as priority, but you could change it by:\n\n```java\nDateParserUtils.preferMonthFirst(true);\nDateParserUtils.parseCalendar(\"08.03.71\");\n// 1971-08-03\nDateParserUtils.preferMonthFirst(false);\nDateParserUtils.parseCalendar(\"08.03.71\");\n// 1971-03-08\n``` \n\nNotice: if either number is larger than `12`, then `preferMonthFirst` wouldn't be effective.\n\n# Customize Parser\n\nYou could use `DateParserBuilder` to build your own parser, \nand customize new rules to parse different input.\n\nLike add support for `【2019】`, which isn't supported by default:\n\n```java\nDateParser parser = DateParser.newBuilder().addRule(\"【(?\u003cyear\u003e\\\\d{4})】\").build();\nCalendar calendar = parser.parseCalendar(\"【1991】\");\nassert calendar.get(Calendar.YEAR) == 1991;\n``` \n\nThe group name `year` is very important, you cannot use other unknown name.\n\nBut, you can register new handler to parse the new rule:\n\n```java\nDateParser parser = DateParser.newBuilder()\n    .addRule(\"民国(\\\\d{3})年\", (input, matcher, dt) -\u003e {\n        int offset = matcher.start(1);\n        int i0 = input.charAt(offset) - '0';\n        int i1 = input.charAt(offset + 1) - '0';\n        int i2 = input.charAt(offset + 2) - '0';\n        dt.setYear(i0 * 100 + i1 * 10 + i2 + 1911);\n    })\n    .build();\nCalendar calendar = parser.parseCalendar(\"民国101年\");\nassert calendar.get(Calendar.YEAR) == 2012;\n```\n\nThe `民国101年` represents `101` years after `1911`. \n\n# Performance\n\nCompared to single `SimpleDateFormat`, the performance of `dateparser`:\n\n```\nBenchmark               Mode  Cnt     Score    Error  Units\nSingleBenchmark.java    avgt    6   921.632 ± 12.299  ns/op\nSingleBenchmark.parser  avgt    6  1553.909 ± 70.664  ns/op\n``` \n\nCompared to single `DateTimeFormatter`, the performance of `dateparser`:\n\n```\nBenchmark                       Mode  Cnt     Score    Error  Units\nSingleDateTimeBenchmark.java    avgt    6   654.553 ± 16.703  ns/op\nSingleDateTimeBenchmark.parser  avgt    6  1680.690 ± 34.214  ns/op\n```\n\nSo, for String with known format, the `dateparser` is slower.\n\nBut if the number of `format` is not single, \nlets increase to `16`, the performance of `dateparser`:\n\n```\nBenchmark              Mode  Cnt      Score      Error  Units\nMultiBenchmark.format  avgt    6  47385.021 ± 1083.649  ns/op\nMultiBenchmark.parser  avgt    6  22852.113 ±  310.720  ns/op\n```\n\n`dateparser` is very stable, with increasing of the number of `format`, it has no performance lose.  \n\nYou can checkout the source code of benchmark at [there](https://github.com/sisyphsu/dateparser/tree/master/src/test/java/com/github/sisyphsu/dateparser/benchmark). \n\n# Showcase\n\nThere are some examples of datetime format which `dateparser` supports:\n\n```\nMay 8, 2009 5:57:51 PM                               \noct 7, 1970                                          \noct 7, '70                                           \noct. 7, 1970                                         \noct. 7, 70                                           \nMon Jan  2 15:04:05 2006                             \nMon Jan  2 15:04:05 MST 2006                         \nMon Jan 02 15:04:05 -0700 2006                       \nMonday, 02-Jan-06 15:04:05 MST                       \nMon, 02 Jan 2006 15:04:05 MST                        \nTue, 11 Jul 2017 16:28:13 +0200 (CEST)               \nMon, 02 Jan 2006 15:04:05 -0700                      \nThu, 4 Jan 2018 17:53:36 +0000                       \nMon Aug 10 15:44:11 UTC+0100 2015                    \nFri Jul 03 2015 18:04:07 GMT+0100 (GMT Daylight Time)\nSeptember 17, 2012 10:09am                         \nSeptember 17, 2012 at 10:09am PST-08               \nSeptember 17, 2012, 10:10:09                       \nOctober 7, 1970                                    \nOctober 7th, 1970                                  \n12 Feb 2006, 19:17                                 \n12 Feb 2006 19:17                                  \n7 oct 70                                           \n7 oct 1970                                         \n03 February 2013                                   \n1 July 2013                                        \n2013-Feb-03                                        \n3/31/2014                                          \n03/31/2014                                         \n08/21/71                                           \n8/1/71                                             \n4/8/2014 22:05                                     \n04/08/2014 22:05                                   \n4/8/14 22:05                                       \n04/2/2014 03:00:51                                 \n8/8/1965 12:00:00 AM                               \n8/8/1965 01:00:01 PM                               \n8/8/1965 01:00 PM                                  \n8/8/1965 1:00 PM                                   \n8/8/1965 12:00 AM                                  \n4/02/2014 03:00:51                                 \n03/19/2012 10:11:59                                \n03/19/2012 10:11:59.3186369                        \n2014/3/31                                          \n2014/03/31                                         \n2014/4/8 22:05                                     \n2014/04/08 22:05                                   \n2014/04/2 03:00:51                                 \n2014/4/02 03:00:51                                 \n2012/03/19 10:11:59                                \n2012/03/19 10:11:59.3186369                        \n2014年04月08日                                      \n2006-01-02T15:04:05+0000                           \n2009-08-12T22:15:09-07:00                          \n2009-08-12T22:15:09                                \n2009-08-12T22:15:09Z                               \n2014-04-26 17:24:37.3186369                        \n2012-08-03 18:31:59.257000000                      \n2014-04-26 17:24:37.123                            \n2013-04-01 22:43                                   \n2013-04-01 22:43:22                                \n2014-12-16 06:20:00 UTC                            \n2014-12-16 06:20:00 GMT                          \n2014-04-26 05:24:37 PM                           \n2014-04-26 13:13:43 +0800                        \n2014-04-26 13:13:43 +0800 +08                    \n2014-04-26 13:13:44 +09:00                       \n2012-08-03 18:31:59.257000000 +0000 UTC          \n2015-09-30 18:48:56.35272715 +0000 UTC           \n2015-02-18 00:12:00 +0000 GMT                    \n2015-02-18 00:12:00 +0000 UTC                    \n2015-02-08 03:02:00 +0300 MSK m=+0.000000001     \n2015-02-08 03:02:00.001 +0300 MSK m=+0.000000001 \n2017-07-19 03:21:51+00:00\n2014-04-26               \n2014-04                  \n2014                     \n2014-05-11 08:20:13,787  \n3.31.2014       \n03.31.2014      \n08.21.71        \n2014.03         \n2014.03.30      \n20140601        \n20140722105203  \n1332151919      \n1384216367189   \n1384216367111222\n1384216367111222333 \n```\n\nLots of these examples were copied from https://github.com/araddon/dateparse.\n\n# Support\n\nLet me know if you meet any issues when using this library.\n\nLet me know if you need any features that this library hasn't yet.\n\nPull Request are welcomed.\n\n# License\n\nMIT\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsisyphsu%2Fdateparser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsisyphsu%2Fdateparser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsisyphsu%2Fdateparser/lists"}