diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..ee4fc95f --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,9 @@ +version: 2 +updates: + - package-ecosystem: maven + directory: "/" + schedule: + interval: daily + open-pull-requests-limit: 10 + labels: + - "dependencies" diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml new file mode 100644 index 00000000..1f73297c --- /dev/null +++ b/.github/workflows/maven.yml @@ -0,0 +1,27 @@ +name: Java CI with Maven + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + name: Java ${{ matrix.java_version }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + java_version: ['8', '11', '17'] + + steps: + - uses: actions/checkout@v3 + - name: Set up JDK ${{ matrix.java_version }} + uses: actions/setup-java@v3 + with: + java-version: ${{ matrix.java_version }} + distribution: 'temurin' + cache: maven + - name: Build with Maven + run: mvn -B package --file pom.xml diff --git a/.gitignore b/.gitignore index 8f3706cb..8a54c833 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,14 @@ .classpath .settings .project -.idea workspace.xml bin target -src/main/java/com/joestelmach/natty/generated/* +src/main/java/org/natty/generated/* src/main/java/*.tokens -src/main/antlr3/com/joestelmach/natty/generated/DebugDateParser.g -src/main/antlr3/com/joestelmach/natty/generated/DebugDateWalker.g +src/main/antlr3/org/natty/generated/DebugDateParser.g +src/main/antlr3/org/natty/generated/DebugDateWalker.g + +# IntelliJ Idea +*.iml +.idea diff --git a/README b/README deleted file mode 100644 index 69d4bdd0..00000000 --- a/README +++ /dev/null @@ -1,7 +0,0 @@ -Natty is a natural language date parser written in Java. Given a date -expression, natty will apply standard language recognition and translation -techniques to produce a list of corresponding dates with optional parse and -syntax information. - -Complete documentation can be found here: -http://natty.joestelmach.com diff --git a/README.md b/README.md new file mode 100644 index 00000000..0dc917bc --- /dev/null +++ b/README.md @@ -0,0 +1,52 @@ +## What + +Natty is a natural language date parser written in Java. Given a date +expression, natty will apply standard language recognition and translation +techniques to produce a list of corresponding dates with optional parse and +syntax information. + +## History + +Originally written by Joel Stelmach at https://github.com/joestelmach/natty and developed between 2010 and 2017. Abandoned since then. + +## Usage +Maven: +``` + + io.github.natty-parser + natty + 1.0.1 + +``` + +or [consult maven.org](https://search.maven.org/artifact/io.github.natty-parser/natty) for other build systems. + +## Idea behind the fork + +Started with [a thread in the original project](https://github.com/joestelmach/natty/issues/274). The aim is to try providing maintenance for the library. + +Plan / Priorities (as of November 2022): + +1. ~~Release version `1.0.0` with (possibly) the same code as the fork root, but under new name, consider renaming packages and artifacts to use `natty-parser` as the moniker, etc.~~ +DONE +2. ~~Fix the tests (some are failing?).~~ DONE +3. Set up basic technicalities of the fork - Maven release process, CI (Continuous Integration), etc. +4. Start accepting contributions (PRs), encourage the community to solve [issues reported in the original repo](https://github.com/joestelmach/natty/issues) +5. Consider switching to Gradle (as this is a build tool which is modern and I am familiar with) +6. Decide on the overall vision of the project - at this point it's hard to tell, but I think a conscious decision on what is gonna be supported would be +great - i.e. focus on i18n, customization, stability, or what? + +## Known issues from the parent project + +See [issues](issues.md) + +## Commitment + +I hope for open collaboration and contributions from others. To me it's totally a side-project, not the core activity. Yet, I can commit to being (fairly) responsive and inclusive. + +## Contibutions + +Are more then welcome. Feel free to reach out (e.g. by creating an issue in this repo) to offer your support and ideas. I am happy to include more +maintainers. Tag @mccartney if no response for 2-3 days (I might have missed that). + +I see this project potentially being welcoming to many, incl. quite junior and inexperienced developers, who would like to learn and contribute. diff --git a/issues.md b/issues.md new file mode 100644 index 00000000..bf72ca1e --- /dev/null +++ b/issues.md @@ -0,0 +1,196 @@ +# Issues from original repository +as of 2022-05-08 + +The issues are grouped into rough categories to make it possible to prioritise them a bit. + +## Crashes + +| ID | Title | +|---------------------------------------------------------|-------------------------------------------------------------------------------------------------------------| +| [#278](https://github.com/joestelmach/natty/issues/278) | 'last easter' gives NPE since 2021 | +| [#277](https://github.com/joestelmach/natty/issues/277) | Cant parse this oddly specific string. | +| [#263](https://github.com/joestelmach/natty/issues/263) | "Christma-eve" before 2000 throws NPE | +| [#246](https://github.com/joestelmach/natty/issues/246) | Could not parse input org.antlr.runtime.EarlyExitException: null | +| [#238](https://github.com/joestelmach/natty/issues/238) | natty line 1:23 no viable alternative at input '4' - Just override the emitErrorMessage method @joestelmach | +| [#236](https://github.com/joestelmach/natty/issues/236) | java.lang.NullPointerException | +| [#234](https://github.com/joestelmach/natty/issues/234) | NullPointerException | +| [#193](https://github.com/joestelmach/natty/issues/193) | NumberFormatException | +| [#190](https://github.com/joestelmach/natty/issues/190) | NullPointerExceptions | +| [#162](https://github.com/joestelmach/natty/issues/162) | NPE / NumberFormatExceptions in WalkerState on Seasons and year seaks with miscalculated target year | +| [#147](https://github.com/joestelmach/natty/issues/147) | NumberFormatException for "match-up on Saturday, February 22, 64-44, against Lynwood" | + +## Errors + Incorrect Parsing + +| ID | Title | +|---------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------| +| [#280](https://github.com/joestelmach/natty/issues/280) | Issues with multiple time points | +| [#279](https://github.com/joestelmach/natty/issues/279) | Incorrectly parsing years as of Jan 1st, 2021 | +| [#275](https://github.com/joestelmach/natty/issues/275) | Can't equate a month with 1 month | +| [#273](https://github.com/joestelmach/natty/issues/273) | Can't parse due to milliseconds | +| [#268](https://github.com/joestelmach/natty/issues/268) | Parser is failing because it doesn't detect date time | +| [#267](https://github.com/joestelmach/natty/issues/267) | In free form text year expression in end is ignored | +| [#266](https://github.com/joestelmach/natty/issues/266) | 19:40 Thursday (May 16, 2019) parsed wrongly | +| [#244](https://github.com/joestelmach/natty/issues/244) | Wrong Date calculated for Days of the week | +| [#243](https://github.com/joestelmach/natty/issues/243) | Can't parse month name on certain locations in text | +| [#227](https://github.com/joestelmach/natty/issues/227) | Date is not identified | +| [#211](https://github.com/joestelmach/natty/issues/211) | Please Correct "this month" result | +| [#210](https://github.com/joestelmach/natty/issues/210) | Dates subsequent to "Weekend" are ignored by parser. | +| [#207](https://github.com/joestelmach/natty/issues/207) | Year boundary condition on "before" | +| [#206](https://github.com/joestelmach/natty/issues/206) | slight date issue | +| [#203](https://github.com/joestelmach/natty/issues/203) | Past year interpretted | +| [#202](https://github.com/joestelmach/natty/issues/202) | Not able to parse if text contains numeric date incorrect subscript | +| [#201](https://github.com/joestelmach/natty/issues/201) | Midnight | +| [#194](https://github.com/joestelmach/natty/issues/194) | Invalid parse of two consecutive dates | +| [#192](https://github.com/joestelmach/natty/issues/192) | Natty parse string with no dates incorrectly | +| [#189](https://github.com/joestelmach/natty/issues/189) | Inconsistent year parsing | +| [#188](https://github.com/joestelmach/natty/issues/188) | Last week vs Last 1 week | +| [#184](https://github.com/joestelmach/natty/issues/184) | yesterday afternoon at 2 | +| [#180](https://github.com/joestelmach/natty/issues/180) | Doesn't seem to parse both times (as a range) | +| [#171](https://github.com/joestelmach/natty/issues/171) | "End of this week", "till this week", "ends this week" are not working | +| [#170](https://github.com/joestelmach/natty/issues/170) | Error with relative dates | +| [#169](https://github.com/joestelmach/natty/issues/169) | Basic parsing is broken | +| [#166](https://github.com/joestelmach/natty/issues/166) | "TEST123" gets parsed as HOURS_OF_DAY 3 | +| [#161](https://github.com/joestelmach/natty/issues/161) | Date is detected in Url | +| [#157](https://github.com/joestelmach/natty/issues/157) | doesnt parse | +| [#155](https://github.com/joestelmach/natty/issues/155) | first monday of next leap year | +| [#152](https://github.com/joestelmach/natty/issues/152) | Improper date format returned | +| [#148](https://github.com/joestelmach/natty/issues/148) | In date ranges, tonight should imply the date (today's date), not just the time (8pm) | +| [#146](https://github.com/joestelmach/natty/issues/146) | "In 2 weeks at 2pm" | +| [#143](https://github.com/joestelmach/natty/issues/143) | Won't parse just the year | +| [#142](https://github.com/joestelmach/natty/issues/142) | A minute ago | +| [#139](https://github.com/joestelmach/natty/issues/139) | the vs. this | +| [#137](https://github.com/joestelmach/natty/issues/137) | "First day of this year" returns current date | +| [#119](https://github.com/joestelmach/natty/issues/119) | "A380 tomorrow" parses as 0 as explicit hour | +| [#96](https://github.com/joestelmach/natty/issues/96) | "an hour ago" and "a minute ago" | +| [#79](https://github.com/joestelmach/natty/issues/79) | "every week" unrecognised | +| [#56](https://github.com/joestelmach/natty/issues/56) | Fails to parse when numbers that are greater than 99 AND divisible by 10 are used | +| [#55](https://github.com/joestelmach/natty/issues/55) | "Before" clause seems not working | +| [#54](https://github.com/joestelmach/natty/issues/54) | Natty parsing failed relative dates | +| [#50](https://github.com/joestelmach/natty/issues/50) | Parsing error | + +## Format issues +| ID | Title | +|---------------------------------------------------------|--------------------------------------------------------------------------------| +| [#271](https://github.com/joestelmach/natty/issues/271) | 9999-12-31 fails to parse | +| [#265](https://github.com/joestelmach/natty/issues/265) | Date parsed wrongly | +| [#260](https://github.com/joestelmach/natty/issues/260) | 04Oct17-31Oct17 | +| [#257](https://github.com/joestelmach/natty/issues/257) | 02sep85 | +| [#254](https://github.com/joestelmach/natty/issues/254) | Problem parsing Oct-07-2018 10:00 | +| [#242](https://github.com/joestelmach/natty/issues/242) | Can't parse ddMMyyyy formate | +| [#241](https://github.com/joestelmach/natty/issues/241) | Question/Issue, dates with no delimiters like 5Jan2018 are parsed in-correctly | +| [#240](https://github.com/joestelmach/natty/issues/240) | Unable to parse "End of the Week" | +| [#237](https://github.com/joestelmach/natty/issues/237) | Wrong parsing in case of % | +| [#229](https://github.com/joestelmach/natty/issues/229) | Not able to parse boundary references | +| [#228](https://github.com/joestelmach/natty/issues/228) | Not able to parse 4MAR17 | +| [#215](https://github.com/joestelmach/natty/issues/215) | The first of the month | +| [#214](https://github.com/joestelmach/natty/issues/214) | Unable to detect date in news article | +| [#212](https://github.com/joestelmach/natty/issues/212) | Can't detect year when spelled out | +| [#208](https://github.com/joestelmach/natty/issues/208) | Placing the year after time causes parsing to change the year | +| [#204](https://github.com/joestelmach/natty/issues/204) | Natty is unable to parse this date | +| [#179](https://github.com/joestelmach/natty/issues/179) | Only date is not being parsed | +| [#167](https://github.com/joestelmach/natty/issues/167) | "2016.06.13 18:42:04" is parsed as "Fri Mar 25 20:16:06 UTC 2016" | +| [#160](https://github.com/joestelmach/natty/issues/160) | @ between date and time | +| [#158](https://github.com/joestelmach/natty/issues/158) | can't parse simple Datetype | +| [#151](https://github.com/joestelmach/natty/issues/151) | no viable alternative at input '' | +| [#144](https://github.com/joestelmach/natty/issues/144) | 15/12/2004 is not parsed correctly. | +| [#118](https://github.com/joestelmach/natty/issues/118) | 29.01.57 is parsed incorrectly | +| [#104](https://github.com/joestelmach/natty/issues/104) | date parsing | +| [#75](https://github.com/joestelmach/natty/issues/75) | 20121028_161105.jpg | + +## Feature requests + +| ID | Title | +|---------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------| +| [#276](https://github.com/joestelmach/natty/issues/276) | Parsing of quarter not supported | +| [#270](https://github.com/joestelmach/natty/issues/270) | support canonical timezone id (not just abbreviations) | +| [#269](https://github.com/joestelmach/natty/issues/269) | Support for countries which use DD MM YYYY | +| [#259](https://github.com/joestelmach/natty/issues/259) | Can't parse time fields like "60s" | +| [#258](https://github.com/joestelmach/natty/issues/258) | Upgrade to Antlr4 | +| [#256](https://github.com/joestelmach/natty/issues/256) | Year is added to current year 2018 jan 15 gives year 4036-01-01 3pm utc [other format] | +| [#255](https://github.com/joestelmach/natty/issues/255) | Year references would be nice to match | +| [#264](https://github.com/joestelmach/natty/issues/264) | "23rd" not getting parsed. Expected result is current_MM/23/current_YYYY | +| [#249](https://github.com/joestelmach/natty/issues/249) | Is it possible to make natty multilingual? | +| [#248](https://github.com/joestelmach/natty/issues/248) | Feature request | +| [#245](https://github.com/joestelmach/natty/issues/245) | Feature Request: Set date format locale on call | +| [#239](https://github.com/joestelmach/natty/issues/239) | A fortnight happens to be absent from Natty's vocabulary | +| [#235](https://github.com/joestelmach/natty/issues/235) | java.lang.IllegalArgumentException: No enum constant com.joestelmach.natty.Holiday.INAUGURATION_DAY | +| [#233](https://github.com/joestelmach/natty/issues/233) | Parsing week numbers | +| [#231](https://github.com/joestelmach/natty/issues/231) | Couple days from now / next leap year | +| [#226](https://github.com/joestelmach/natty/issues/226) | RFC 2822 Support | +| [#223](https://github.com/joestelmach/natty/issues/223) | Add support for several languages | +| [#222](https://github.com/joestelmach/natty/issues/222) | time period recognition | +| [#221](https://github.com/joestelmach/natty/issues/221) | Add time grain for date parsed | +| [#220](https://github.com/joestelmach/natty/issues/220) | Add support for "1h2m" format? | +| [#216](https://github.com/joestelmach/natty/issues/216) | First Quarter / Q1-Q3 | +| [#205](https://github.com/joestelmach/natty/issues/205) | Unable to distinguish time range | +| [#200](https://github.com/joestelmach/natty/issues/200) | some day in the feature | +| [#198](https://github.com/joestelmach/natty/issues/198) | 21st Oct last year is not supported | +| [#197](https://github.com/joestelmach/natty/issues/197) | Not accepting the week after | +| [#191](https://github.com/joestelmach/natty/issues/191) | "Mid August" parses to Aug. 01 | +| [#187](https://github.com/joestelmach/natty/issues/187) | Unable to determine the following date type | +| [#186](https://github.com/joestelmach/natty/issues/186) | Enhancement: Locale/Internationalization support? | +| [#185](https://github.com/joestelmach/natty/issues/185) | Can't parse date from this :NT INT INST 2005 06 08 Let ECGD du 29 mars.pdf | +| [#183](https://github.com/joestelmach/natty/issues/183) | quarter is not parsed | +| [#182](https://github.com/joestelmach/natty/issues/182) | 25th of every month is not parsed | +| [#181](https://github.com/joestelmach/natty/issues/181) | Can't parse short format: 3h ago | +| [#177](https://github.com/joestelmach/natty/issues/177) | Doesn't recognize "Last quarter" | +| [#172](https://github.com/joestelmach/natty/issues/172) | Does not recognize 'previous' keyword | +| [#168](https://github.com/joestelmach/natty/issues/168) | Natty ignores milliseconds | +| [#159](https://github.com/joestelmach/natty/issues/159) | parsing text with numbers | +| [#153](https://github.com/joestelmach/natty/issues/153) | Date ranges? | +| [#150](https://github.com/joestelmach/natty/issues/150) | "the beginning of (next) year" | +| [#140](https://github.com/joestelmach/natty/issues/140) | recognize before month | +| [#138](https://github.com/joestelmach/natty/issues/138) | Quarters | +| [#134](https://github.com/joestelmach/natty/issues/134) | Incorrect parsing for dd-mm-yyyy and similar | +| [#132](https://github.com/joestelmach/natty/issues/132) | Handle "Next Business Day" and "As Soon As Possible" | +| [#129](https://github.com/joestelmach/natty/issues/129) | How to refer to beginning of (computer) time? | +| [#123](https://github.com/joestelmach/natty/issues/123) | Parsing strings with only year information | +| [#122](https://github.com/joestelmach/natty/issues/122) | How to translate natty recognition in other languages | +| [#121](https://github.com/joestelmach/natty/issues/121) | prefixes "3 days from " doesn't seem to work | +| [#120](https://github.com/joestelmach/natty/issues/120) | Date range doesn't take into account day of week | +| [#114](https://github.com/joestelmach/natty/issues/114) | Relative dates with respect to another date rather than now | +| [#110](https://github.com/joestelmach/natty/issues/110) | "JUNE 9TH - JUNE 23RD, 2014" is parsed as 06/09/201*5* - 06/23/2014 | +| [#106](https://github.com/joestelmach/natty/issues/106) | how to parse twelve to ten? | +| [#105](https://github.com/joestelmach/natty/issues/105) | java time zoneddatetime to string should be supported | +| [#93](https://github.com/joestelmach/natty/issues/93) | need week end and work day aliases as we have for holidays | +| [#80](https://github.com/joestelmach/natty/issues/80) | Four score and ten years ago | +| [#77](https://github.com/joestelmach/natty/issues/77) | Recalculate a time- inferred date | +| [#69](https://github.com/joestelmach/natty/issues/69) | Year bias... | +| [#64](https://github.com/joestelmach/natty/issues/64) | How to parse dates of format DD/MM/YYYY? | +| [#57](https://github.com/joestelmach/natty/issues/57) | Fails to parse day of month (eg: "the 21st") | +| [#53](https://github.com/joestelmach/natty/issues/53) | Include possible date/time range ? | +| [#48](https://github.com/joestelmach/natty/issues/48) | I18n support - different languages/countries | +| [#47](https://github.com/joestelmach/natty/issues/47) | Make CalendarSource.setBaseDate an instance method | +| [#44](https://github.com/joestelmach/natty/issues/44) | friendlier time rules | +| [#41](https://github.com/joestelmach/natty/issues/41) | Feature: Future dates only option | +| [#26](https://github.com/joestelmach/natty/issues/26) | Not Parsing "March 9-13, 2012" properly | +| [#25](https://github.com/joestelmach/natty/issues/25) | can not parse "2011-09-12T13:55:00.004+02:00" | +| [#23](https://github.com/joestelmach/natty/issues/23) | "each sunday in march" did not parse | +| [#21](https://github.com/joestelmach/natty/issues/21) | French Dates Like 07-10-2011 | +| [#20](https://github.com/joestelmach/natty/issues/20) | German Dates Like 07.10.2011 | +| [#17](https://github.com/joestelmach/natty/issues/17) | Feature requests: More date ranges, custom event support | +| [#16](https://github.com/joestelmach/natty/issues/16) | Cannot parse Sat., Sept. 24, 10:30 a.m.-9 p.m. format | +| [#6](https://github.com/joestelmach/natty/issues/6) | Add time precision option | +| [#3](https://github.com/joestelmach/natty/issues/3) | UK-formatted dates won't parse | + +## Misc + +| ID | Title | +|---------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------| +| [#281](https://github.com/joestelmach/natty/issues/281) | Documentation - 500 internal server error - http://natty.joestelmach.com/ | +| [#274](https://github.com/joestelmach/natty/issues/274) | abandonware and forks diverge wildly | +| [#253](https://github.com/joestelmach/natty/issues/253) | Runtime VerifyError: Verifier rejected class with Android <= 21 | +| [#251](https://github.com/joestelmach/natty/issues/251) | Strange Memory Issue (leak) | +| [#230](https://github.com/joestelmach/natty/issues/230) | Can't import project into android studio | +| [#219](https://github.com/joestelmach/natty/issues/219) | How can I add a needed format? | +| [#218](https://github.com/joestelmach/natty/issues/218) | Inferences could be more specific | +| [#217](https://github.com/joestelmach/natty/issues/217) | Upgrade to ical4j 2.0 | +| [#199](https://github.com/joestelmach/natty/issues/199) | how to get rid of: [main] INFO com.joestelmach.natty.Parser - STREAM | +| [#195](https://github.com/joestelmach/natty/issues/195) | Getting date format from parser | +| [#165](https://github.com/joestelmach/natty/issues/165) | Parser logs are too verbose at INFO | +| [#156](https://github.com/joestelmach/natty/issues/156) | How do I mute console output? | +| [#149](https://github.com/joestelmach/natty/issues/149) | Daylight savings logic? | +| [#135](https://github.com/joestelmach/natty/issues/135) | SLF4J for class DateParser_NumericRules | +| [#95](https://github.com/joestelmach/natty/issues/95) | Usage questions related to multiple groups/dates returned by parser | +| [#84](https://github.com/joestelmach/natty/issues/84) | Javascript version? | +| [#52](https://github.com/joestelmach/natty/issues/52) | Can i change in the java source code and create it's new jar without using maven and if no how can i do that using maven ? | \ No newline at end of file diff --git a/natty.iml b/natty.iml deleted file mode 100644 index b8cf0290..00000000 --- a/natty.iml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/pom.xml b/pom.xml index c8db661e..6c58d020 100644 --- a/pom.xml +++ b/pom.xml @@ -1,44 +1,45 @@ 4.0.0 - com.joestelmach + io.github.natty-parser natty jar - 0.14-SNAPSHOT + 1.0.1 Natty Date Parser natural language date parser - http://natty.joestelmach.com + https://github.com/natty-parser/natty MIT License - LICENSE + https://opensource.org/licenses/MIT - scm:git:git@github.com:joestelmach/natty.git - scm:git:git@github.com:joestelmach/natty.git - scm:git:git@github.com:joestelmach/natty.git + scm:git:git@github.com:natty-parser/natty.git + scm:git:git@github.com:natty-parser/natty.git + scm:git:git@github.com:natty-parser/natty.git - joe - Joe Stelmach - joestelmach@gmail.com - http://github.com/joestelmach + mccartney + Greg Oledzki + http://github.com/mccartney developer - -5 + 1 - ${basedir}/src/main/antlr3/com/joestelmach/natty/generated + ${basedir}/src/main/antlr3/org/natty/generated UTF-8 UTF-8 -Xdoclint:none + 1.8 + 1.8 @@ -62,11 +63,11 @@ org.sonatype.plugins nexus-staging-maven-plugin - 1.6.7 + 1.6.13 true ossrh - https://oss.sonatype.org/ + https://s01.oss.sonatype.org/ true @@ -75,7 +76,7 @@ org.apache.maven.plugins maven-release-plugin - 2.0 + 2.5.3 forked-path @@ -84,21 +85,17 @@ maven-compiler-plugin - 2.3.2 - - 1.6 - 1.6 - + 3.10.1 maven-clean-plugin - 2.4.1 + 3.2.0 - src/main/java/com/joestelmach/natty/generated + src/main/java/org/natty/generated **/*.java @@ -112,7 +109,7 @@ org.antlr antlr3-maven-plugin - 3.5.2 + 3.5.3 @@ -122,14 +119,14 @@ true - src/main/antlr3/com/joestelmach/natty/generated/imports + src/main/antlr3/org/natty/generated/imports src/main/java - com/joestelmach/natty/generated/DateLexer.g - com/joestelmach/natty/generated/DateParser.g + org/natty/generated/DateLexer.g + org/natty/generated/DateParser.g - com/joestelmach/natty/generated/imports/NumericRules.g + org/natty/generated/imports/NumericRules.g @@ -142,11 +139,11 @@ false src/main/java - src/main/antlr3/com/joestelmach/natty/generated/imports + src/main/antlr3/org/natty/generated/imports - com/joestelmach/natty/generated/DateLexer.g - com/joestelmach/natty/generated/DateParser.g - com/joestelmach/natty/generated/imports/NumericRules.g + org/natty/generated/DateLexer.g + org/natty/generated/DateParser.g + org/natty/generated/imports/NumericRules.g @@ -158,7 +155,7 @@ org.antlr maven-gunit-plugin - 3.5.2 + 3.5.3 maven-gunit-plugin @@ -189,7 +186,7 @@ org.apache.maven.plugins maven-gpg-plugin - 1.6 + 3.0.1 sign-artifacts @@ -201,29 +198,29 @@ - org.apache.maven.plugins - maven-javadoc-plugin - 2.10.4 + maven-source-plugin + 3.2.1 - attach-javadocs + attach-sources - jar + jar-no-fork - - org.apache.maven.plugins - maven-source-plugin - 3.0.1 + maven-javadoc-plugin + 3.4.1 + + + - attach-sources + attach-javadocs jar @@ -240,39 +237,45 @@ org.antlr antlr-runtime - 3.5.2 + 3.5.3 org.mnode.ical4j ical4j - 1.0.2 + 3.2.7 org.slf4j slf4j-api - 1.7.10 + 2.0.3 org.slf4j slf4j-log4j12 - 1.7.10 + 1.7.33 test + + + ch.qos.logback + logback-classic + 1.3.4 + junit junit - 4.1 + 4.13.2 test org.antlr gunit - 3.5.2 + 3.5.3 test diff --git a/src/main/antlr3/com/joestelmach/natty/generated/DateLexer.g b/src/main/antlr3/org/natty/generated/DateLexer.g similarity index 98% rename from src/main/antlr3/com/joestelmach/natty/generated/DateLexer.g rename to src/main/antlr3/org/natty/generated/DateLexer.g index 5f85fa30..1e2d06f4 100644 --- a/src/main/antlr3/com/joestelmach/natty/generated/DateLexer.g +++ b/src/main/antlr3/org/natty/generated/DateLexer.g @@ -1,10 +1,10 @@ lexer grammar DateLexer; -@header { package com.joestelmach.natty.generated; } +@header { package org.natty.generated; } @members { private static org.slf4j.Logger _logger = - org.slf4j.LoggerFactory.getLogger(com.joestelmach.natty.generated.DateLexer.class); + org.slf4j.LoggerFactory.getLogger(org.natty.generated.DateLexer.class); @Override public void displayRecognitionError(String[] tokenNames, RecognitionException re) { diff --git a/src/main/antlr3/com/joestelmach/natty/generated/DateParser.g b/src/main/antlr3/org/natty/generated/DateParser.g similarity index 99% rename from src/main/antlr3/com/joestelmach/natty/generated/DateParser.g rename to src/main/antlr3/org/natty/generated/DateParser.g index d3c99128..a4addaa4 100644 --- a/src/main/antlr3/com/joestelmach/natty/generated/DateParser.g +++ b/src/main/antlr3/org/natty/generated/DateParser.g @@ -37,12 +37,12 @@ tokens { } @header { - package com.joestelmach.natty.generated; + package org.natty.generated; } @members { private static org.slf4j.Logger _logger = - org.slf4j.LoggerFactory.getLogger(com.joestelmach.natty.generated.DateParser.class); + org.slf4j.LoggerFactory.getLogger(org.natty.generated.DateParser.class); @Override public void displayRecognitionError(String[] tokenNames, RecognitionException re) { diff --git a/src/main/antlr3/com/joestelmach/natty/generated/DateWalker.g b/src/main/antlr3/org/natty/generated/DateWalker.g similarity index 93% rename from src/main/antlr3/com/joestelmach/natty/generated/DateWalker.g rename to src/main/antlr3/org/natty/generated/DateWalker.g index 8d87db3b..0d198147 100644 --- a/src/main/antlr3/com/joestelmach/natty/generated/DateWalker.g +++ b/src/main/antlr3/org/natty/generated/DateWalker.g @@ -5,10 +5,10 @@ options { ASTLabelType=CommonTree; } -@header { package com.joestelmach.natty.generated; } +@header { package org.natty.generated; } @members { - private com.joestelmach.natty.WalkerState _walkerState; + private org.natty.WalkerState _walkerState; private java.util.Date referenceDate; @Override @@ -27,9 +27,9 @@ options { this.referenceDate = referenceDate; } - public com.joestelmach.natty.WalkerState getState() { + public org.natty.WalkerState getState() { if(_walkerState==null) { - _walkerState = new com.joestelmach.natty.WalkerState(referenceDate); + _walkerState = new org.natty.WalkerState(referenceDate); } return _walkerState; } diff --git a/src/main/antlr3/com/joestelmach/natty/generated/TreeRewrite.g b/src/main/antlr3/org/natty/generated/TreeRewrite.g similarity index 96% rename from src/main/antlr3/com/joestelmach/natty/generated/TreeRewrite.g rename to src/main/antlr3/org/natty/generated/TreeRewrite.g index 4ca30869..f34be981 100644 --- a/src/main/antlr3/com/joestelmach/natty/generated/TreeRewrite.g +++ b/src/main/antlr3/org/natty/generated/TreeRewrite.g @@ -7,7 +7,7 @@ options { filter=true; } -@header { package com.joestelmach.natty.generated; } +@header { package org.natty.generated; } @members { @Override diff --git a/src/main/antlr3/com/joestelmach/natty/generated/imports/NumericRules.g b/src/main/antlr3/org/natty/generated/imports/NumericRules.g similarity index 100% rename from src/main/antlr3/com/joestelmach/natty/generated/imports/NumericRules.g rename to src/main/antlr3/org/natty/generated/imports/NumericRules.g diff --git a/src/main/java/com/joestelmach/natty/ANTLRNoCaseInputStream.java b/src/main/java/org/natty/ANTLRNoCaseInputStream.java similarity index 95% rename from src/main/java/com/joestelmach/natty/ANTLRNoCaseInputStream.java rename to src/main/java/org/natty/ANTLRNoCaseInputStream.java index 48448f75..30e86dcd 100644 --- a/src/main/java/com/joestelmach/natty/ANTLRNoCaseInputStream.java +++ b/src/main/java/org/natty/ANTLRNoCaseInputStream.java @@ -1,4 +1,4 @@ -package com.joestelmach.natty; +package org.natty; import java.io.IOException; import java.io.InputStream; diff --git a/src/main/java/com/joestelmach/natty/CalendarSource.java b/src/main/java/org/natty/CalendarSource.java similarity index 95% rename from src/main/java/com/joestelmach/natty/CalendarSource.java rename to src/main/java/org/natty/CalendarSource.java index fea7a30b..bd89e44a 100644 --- a/src/main/java/com/joestelmach/natty/CalendarSource.java +++ b/src/main/java/org/natty/CalendarSource.java @@ -1,4 +1,4 @@ -package com.joestelmach.natty; +package org.natty; import java.util.Date; import java.util.GregorianCalendar; diff --git a/src/main/java/com/joestelmach/natty/DateGroup.java b/src/main/java/org/natty/DateGroup.java similarity index 98% rename from src/main/java/com/joestelmach/natty/DateGroup.java rename to src/main/java/org/natty/DateGroup.java index 5adb99eb..87c8f90f 100644 --- a/src/main/java/com/joestelmach/natty/DateGroup.java +++ b/src/main/java/org/natty/DateGroup.java @@ -1,4 +1,4 @@ -package com.joestelmach.natty; +package org.natty; import org.antlr.runtime.tree.Tree; @@ -31,7 +31,7 @@ public DateGroup() { /** * Adds a date to this group - * @param date + * @param date the date */ public void addDate(Date date) { _dates.add(date); @@ -77,7 +77,7 @@ public String getFullText() { /** * The line within the fullText this date group is found on - * @return + * @return line number */ public int getLine() { return _line; diff --git a/src/main/java/com/joestelmach/natty/Holiday.java b/src/main/java/org/natty/Holiday.java similarity index 97% rename from src/main/java/com/joestelmach/natty/Holiday.java rename to src/main/java/org/natty/Holiday.java index fdb5414f..773a7b68 100644 --- a/src/main/java/com/joestelmach/natty/Holiday.java +++ b/src/main/java/org/natty/Holiday.java @@ -1,4 +1,4 @@ -package com.joestelmach.natty; +package org.natty; import java.util.HashMap; import java.util.Map; diff --git a/src/main/java/com/joestelmach/natty/IcsSearcher.java b/src/main/java/org/natty/IcsSearcher.java similarity index 99% rename from src/main/java/com/joestelmach/natty/IcsSearcher.java rename to src/main/java/org/natty/IcsSearcher.java index ddf058d3..521fde3b 100644 --- a/src/main/java/com/joestelmach/natty/IcsSearcher.java +++ b/src/main/java/org/natty/IcsSearcher.java @@ -1,4 +1,4 @@ -package com.joestelmach.natty; +package org.natty; import net.fortuna.ical4j.data.CalendarBuilder; import net.fortuna.ical4j.data.ParserException; diff --git a/src/main/java/com/joestelmach/natty/NattyTokenSource.java b/src/main/java/org/natty/NattyTokenSource.java similarity index 95% rename from src/main/java/com/joestelmach/natty/NattyTokenSource.java rename to src/main/java/org/natty/NattyTokenSource.java index cc69972f..3944e786 100644 --- a/src/main/java/com/joestelmach/natty/NattyTokenSource.java +++ b/src/main/java/org/natty/NattyTokenSource.java @@ -1,4 +1,4 @@ -package com.joestelmach.natty; +package org.natty; import java.util.List; diff --git a/src/main/java/com/joestelmach/natty/ParseListener.java b/src/main/java/org/natty/ParseListener.java similarity index 98% rename from src/main/java/com/joestelmach/natty/ParseListener.java rename to src/main/java/org/natty/ParseListener.java index 6784eb35..3a3b8454 100644 --- a/src/main/java/com/joestelmach/natty/ParseListener.java +++ b/src/main/java/org/natty/ParseListener.java @@ -1,4 +1,4 @@ -package com.joestelmach.natty; +package org.natty; import org.antlr.runtime.RecognitionException; import org.antlr.runtime.Token; diff --git a/src/main/java/com/joestelmach/natty/ParseLocation.java b/src/main/java/org/natty/ParseLocation.java similarity index 96% rename from src/main/java/com/joestelmach/natty/ParseLocation.java rename to src/main/java/org/natty/ParseLocation.java index 3636d024..c69a042a 100644 --- a/src/main/java/com/joestelmach/natty/ParseLocation.java +++ b/src/main/java/org/natty/ParseLocation.java @@ -1,4 +1,4 @@ -package com.joestelmach.natty; +package org.natty; /** * Represents an invocation of a parse rule diff --git a/src/main/java/com/joestelmach/natty/Parser.java b/src/main/java/org/natty/Parser.java similarity index 95% rename from src/main/java/com/joestelmach/natty/Parser.java rename to src/main/java/org/natty/Parser.java index 9a0f666f..a4f7a300 100644 --- a/src/main/java/com/joestelmach/natty/Parser.java +++ b/src/main/java/org/natty/Parser.java @@ -1,9 +1,9 @@ -package com.joestelmach.natty; +package org.natty; -import com.joestelmach.natty.generated.DateLexer; -import com.joestelmach.natty.generated.DateParser; -import com.joestelmach.natty.generated.DateWalker; -import com.joestelmach.natty.generated.TreeRewrite; +import org.natty.generated.DateLexer; +import org.natty.generated.DateParser; +import org.natty.generated.DateWalker; +import org.natty.generated.TreeRewrite; import org.antlr.runtime.*; import org.antlr.runtime.tree.CommonTree; import org.antlr.runtime.tree.CommonTreeNodeStream; @@ -43,7 +43,7 @@ public class Parser { /** * Creates a new parser using the given time zone as the default - * @param defaultTimeZone + * @param defaultTimeZone the timezone */ public Parser(TimeZone defaultTimeZone) { _defaultTimeZone = defaultTimeZone; @@ -57,11 +57,10 @@ public Parser() { } /** - * Parses the given input value for one or more groups of - * date alternatives + * Parses the given input value for one or more groups of date alternatives * - * @param value - * @return + * @param value the date to parse + * @return list of date alternatives */ public List parse(String value) { return parse(value, new Date()); @@ -72,9 +71,9 @@ public List parse(String value) { * date alternatives with relative dates resolved according * to referenceDate * - * @param value - * @param referenceDate - * @return + * @param value the date string to parse + * @param referenceDate the reference date for relative dates + * @return list of date alternatives */ public List parse(String value, Date referenceDate) { diff --git a/src/main/java/com/joestelmach/natty/Season.java b/src/main/java/org/natty/Season.java similarity index 95% rename from src/main/java/com/joestelmach/natty/Season.java rename to src/main/java/org/natty/Season.java index b0f5f8a9..3bc73bb7 100644 --- a/src/main/java/com/joestelmach/natty/Season.java +++ b/src/main/java/org/natty/Season.java @@ -1,4 +1,4 @@ -package com.joestelmach.natty; +package org.natty; import java.util.HashMap; import java.util.Map; diff --git a/src/main/java/com/joestelmach/natty/WalkerState.java b/src/main/java/org/natty/WalkerState.java similarity index 97% rename from src/main/java/com/joestelmach/natty/WalkerState.java rename to src/main/java/org/natty/WalkerState.java index 58f29ee3..f69a6736 100644 --- a/src/main/java/com/joestelmach/natty/WalkerState.java +++ b/src/main/java/org/natty/WalkerState.java @@ -1,4 +1,4 @@ -package com.joestelmach.natty; +package org.natty; import java.util.*; @@ -63,8 +63,8 @@ public void setDefaultTimeZone(final TimeZone zone) { * seeks to a specified day of the week in the past or future. * * @param direction the direction to seek: two possibilities - * '<' go backward - * '>' go forward + * '<' go backward + * '>' go forward * * @param seekType the type of seek to perform (by_day or by_week) * by_day means we seek to the very next occurrence of the given day @@ -142,8 +142,8 @@ public void seekToDayOfYear(String dayOfYear) { } /** - * - * @param year + * Seek to the given year + * @param year the year to seek to. */ public void seekToYear(String year) { int yearInt = Integer.parseInt(year); @@ -158,8 +158,8 @@ public void seekToYear(String year) { * seeks to a particular month * * @param direction the direction to seek: two possibilities - * '<' go backward - * '>' go forward + * '<' go backward + * '>' go forward * * @param seekAmount the amount to seek. Must be guaranteed to parse as an integer * @@ -197,12 +197,12 @@ public void seekToMonth(String direction, String seekAmount, String month) { * seeks by a span of time (weeks, months, etc) * * @param direction the direction to seek: two possibilities - * '<' go backward - * '>' go forward + * '<' go backward + * '>' go forward * * @param seekAmount the amount to seek. Must be guaranteed to parse as an integer * - * @param span + * @param span the span to seek by, one of DAY, WEEK, MONTH, YEAR, HOUR, MINUTE, SECOND */ public void seekBySpan(String direction, String seekAmount, String span) { if(span.startsWith(SEEK_PREFIX)) span = span.substring(3); @@ -234,12 +234,7 @@ public void seekBySpan(String direction, String seekAmount, String span) { null; if(field > 0) _calendar.add(field, seekAmountInt * sign); } - - /** - * - * @param index - * @param dayOfWeek - */ + public void setDayOfWeekIndex(String index, String dayOfWeek) { int indexInt = Integer.parseInt(index); assert(indexInt > 0 && indexInt < 6); @@ -314,7 +309,7 @@ else if(dayOfWeek != null) { } /** - * Sets the the time of day + * Sets the time of day * * @param hours the hours to set. Must be guaranteed to parse as an * integer between 0 and 23 @@ -395,9 +390,9 @@ public void seekToHoliday(String holidayString, String direction, String seekAmo /** * Seeks to the given holiday within the given year - * - * @param holidayString - * @param yearString + * @see Holiday + * @param holidayString the name of the holiday as per Holiday enum + * @param yearString the year */ public void seekToHolidayYear(String holidayString, String yearString) { Holiday holiday = Holiday.valueOf(holidayString); @@ -423,8 +418,8 @@ public void seekToSeason(String seasonString, String direction, String seekAmoun /** * Seeks to the given season within the given year * - * @param seasonString - * @param yearString + * @param seasonString The season to seek to + * @param yearString The year */ public void seekToSeasonYear(String seasonString, String yearString) { Season season = Season.valueOf(seasonString); diff --git a/src/test/gunit/DateLexer.testsuite b/src/test/gunit/DateLexer.testsuite index 7ccea6a7..fa895a93 100644 --- a/src/test/gunit/DateLexer.testsuite +++ b/src/test/gunit/DateLexer.testsuite @@ -1,5 +1,5 @@ gunit Date; -@header{package com.joestelmach.natty.generated;} +@header{package org.natty.generated;} JANUARY: "january" OK diff --git a/src/test/java/com/joestelmach/natty/AbstractTest.java b/src/test/java/org/natty/AbstractTest.java similarity index 99% rename from src/test/java/com/joestelmach/natty/AbstractTest.java rename to src/test/java/org/natty/AbstractTest.java index 34e235df..32382b2e 100644 --- a/src/test/java/com/joestelmach/natty/AbstractTest.java +++ b/src/test/java/org/natty/AbstractTest.java @@ -1,4 +1,4 @@ -package com.joestelmach.natty; +package org.natty; import org.junit.Assert; import org.junit.Before; diff --git a/src/test/java/com/joestelmach/natty/CPANTest.java b/src/test/java/org/natty/CPANTest.java similarity index 96% rename from src/test/java/com/joestelmach/natty/CPANTest.java rename to src/test/java/org/natty/CPANTest.java index c1081e5a..df3a0eed 100644 --- a/src/test/java/com/joestelmach/natty/CPANTest.java +++ b/src/test/java/org/natty/CPANTest.java @@ -1,4 +1,4 @@ -package com.joestelmach.natty; +package org.natty; import java.io.BufferedReader; import java.io.InputStreamReader; diff --git a/src/test/java/com/joestelmach/natty/DateTest.java b/src/test/java/org/natty/DateTest.java similarity index 99% rename from src/test/java/com/joestelmach/natty/DateTest.java rename to src/test/java/org/natty/DateTest.java index c0152878..8b9ec017 100644 --- a/src/test/java/com/joestelmach/natty/DateTest.java +++ b/src/test/java/org/natty/DateTest.java @@ -1,4 +1,4 @@ -package com.joestelmach.natty; +package org.natty; import junit.framework.Assert; import org.apache.log4j.Level; @@ -346,7 +346,7 @@ public void testRange() throws Exception { validateDate(dates.get(1), 5, 2, 2011); } - // https://github.com/joestelmach/natty/issues/38 + // https://github.org/natty/issues/38 @Test public void testRelativeDateDifferentTimezone() { // Prepare diff --git a/src/test/java/com/joestelmach/natty/DateTimeTest.java b/src/test/java/org/natty/DateTimeTest.java similarity index 95% rename from src/test/java/com/joestelmach/natty/DateTimeTest.java rename to src/test/java/org/natty/DateTimeTest.java index e1f3570f..a775fa3a 100644 --- a/src/test/java/com/joestelmach/natty/DateTimeTest.java +++ b/src/test/java/org/natty/DateTimeTest.java @@ -1,10 +1,12 @@ -package com.joestelmach.natty; +package org.natty; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; +import java.sql.Timestamp; import java.text.DateFormat; +import java.time.LocalDateTime; import java.util.Date; import java.util.List; import java.util.Locale; @@ -24,9 +26,9 @@ public static void oneTime() { } @Test - public void testSpecific() throws Exception { - Date reference = DateFormat.getDateTimeInstance(DateFormat.SHORT, - DateFormat.SHORT).parse("5/19/2012 12:00 am"); + public void testSpecific() { + final LocalDateTime refDateTime = LocalDateTime.of(2012, 5, 19, 12, 00, 00); + Date reference = Timestamp.valueOf(refDateTime); calendarSource = new CalendarSource(reference); validateDateTime(reference, "1st oct in the year '89 1300 hours", 10, 1, 1989, 13, 0, 0); @@ -46,9 +48,9 @@ public void testSpecific() throws Exception { } @Test - public void testRelative() throws Exception { - Date reference = DateFormat.getDateTimeInstance(DateFormat.SHORT, - DateFormat.SHORT).parse("2/24/2011 12:00 am"); + public void testRelative() { + final LocalDateTime refDateTime = LocalDateTime.of(2011, 2, 24, 0, 0, 0); + Date reference = Timestamp.valueOf(refDateTime); calendarSource = new CalendarSource(reference); validateDateTime(reference, "seven years ago at 3pm", 2, 24, 2004, 15, 0, 0); diff --git a/src/test/java/com/joestelmach/natty/IcsTest.java b/src/test/java/org/natty/IcsTest.java similarity index 99% rename from src/test/java/com/joestelmach/natty/IcsTest.java rename to src/test/java/org/natty/IcsTest.java index 48836955..78e16970 100644 --- a/src/test/java/com/joestelmach/natty/IcsTest.java +++ b/src/test/java/org/natty/IcsTest.java @@ -1,4 +1,4 @@ -package com.joestelmach.natty; +package org.natty; import org.junit.BeforeClass; import org.junit.Test; diff --git a/src/test/java/com/joestelmach/natty/RecurrenceTest.java b/src/test/java/org/natty/RecurrenceTest.java similarity index 85% rename from src/test/java/com/joestelmach/natty/RecurrenceTest.java rename to src/test/java/org/natty/RecurrenceTest.java index f306c502..87783026 100644 --- a/src/test/java/com/joestelmach/natty/RecurrenceTest.java +++ b/src/test/java/org/natty/RecurrenceTest.java @@ -1,6 +1,8 @@ -package com.joestelmach.natty; +package org.natty; +import java.sql.Timestamp; import java.text.DateFormat; +import java.time.LocalDateTime; import java.util.Date; import java.util.Locale; import java.util.TimeZone; @@ -24,8 +26,9 @@ public static void oneTime() { @Test public void testRelative() throws Exception { - Date reference = DateFormat.getDateTimeInstance(DateFormat.SHORT, - DateFormat.SHORT).parse("3/3/2011 12:00 am"); + + final LocalDateTime refDateTime = LocalDateTime.of(2011, 3, 3, 12, 00, 00); + Date reference = Timestamp.valueOf(refDateTime); calendarSource = new CalendarSource(reference); DateGroup group = _parser.parse("every friday until two tuesdays from now", reference).get(0); diff --git a/src/test/java/com/joestelmach/natty/SearchTest.java b/src/test/java/org/natty/SearchTest.java similarity index 99% rename from src/test/java/com/joestelmach/natty/SearchTest.java rename to src/test/java/org/natty/SearchTest.java index 2df0adac..140375d8 100644 --- a/src/test/java/com/joestelmach/natty/SearchTest.java +++ b/src/test/java/org/natty/SearchTest.java @@ -1,4 +1,4 @@ -package com.joestelmach.natty; +package org.natty; import junit.framework.Assert; import org.junit.BeforeClass; diff --git a/src/test/java/com/joestelmach/natty/ThreadSafetyTest.java b/src/test/java/org/natty/ThreadSafetyTest.java similarity index 87% rename from src/test/java/com/joestelmach/natty/ThreadSafetyTest.java rename to src/test/java/org/natty/ThreadSafetyTest.java index 8d2774dc..4179e897 100644 --- a/src/test/java/com/joestelmach/natty/ThreadSafetyTest.java +++ b/src/test/java/org/natty/ThreadSafetyTest.java @@ -1,6 +1,8 @@ -package com.joestelmach.natty; +package org.natty; +import java.sql.Timestamp; import java.text.DateFormat; +import java.time.LocalDateTime; import java.util.Date; import java.util.Locale; import java.util.concurrent.atomic.AtomicInteger; @@ -48,14 +50,14 @@ private class Tester implements Runnable { private int baseMinute; public Tester(int baseMinute) throws Exception { - String date = String.format("3/3/2011 1:%02d am", baseMinute); - this.referenceDate = dateFormat.parse(date); + final LocalDateTime refDateTime = LocalDateTime.of(2011, 3, 3, 1, baseMinute, 0); + this.referenceDate = Timestamp.valueOf(refDateTime); this.baseMinute = baseMinute; } public void run() { try { - // Immitate some long running task. + // Imitate some long running task. Thread.sleep(100); } catch (Exception e) { } String newDate = "4/4/2012"; diff --git a/src/test/java/com/joestelmach/natty/TimeTest.java b/src/test/java/org/natty/TimeTest.java similarity index 99% rename from src/test/java/com/joestelmach/natty/TimeTest.java rename to src/test/java/org/natty/TimeTest.java index 3d4bb70e..671ff3ad 100644 --- a/src/test/java/com/joestelmach/natty/TimeTest.java +++ b/src/test/java/org/natty/TimeTest.java @@ -1,4 +1,4 @@ -package com.joestelmach.natty; +package org.natty; import org.junit.Assert; import org.junit.BeforeClass; diff --git a/src/test/java/com/joestelmach/natty/TimeZoneTest.java b/src/test/java/org/natty/TimeZoneTest.java similarity index 88% rename from src/test/java/com/joestelmach/natty/TimeZoneTest.java rename to src/test/java/org/natty/TimeZoneTest.java index 5dfb8308..33881f03 100644 --- a/src/test/java/com/joestelmach/natty/TimeZoneTest.java +++ b/src/test/java/org/natty/TimeZoneTest.java @@ -1,9 +1,11 @@ -package com.joestelmach.natty; +package org.natty; import org.junit.BeforeClass; import org.junit.Test; +import java.sql.Timestamp; import java.text.DateFormat; +import java.time.LocalDateTime; import java.util.Date; import java.util.Locale; import java.util.TimeZone; @@ -19,8 +21,8 @@ public static void oneTime() { @Test public void testSpecific() throws Exception { - Date reference = DateFormat.getDateTimeInstance(DateFormat.SHORT, - DateFormat.SHORT).parse("5/19/2012 12:00 am"); + final LocalDateTime refDateTime = LocalDateTime.of(2012, 5, 19, 12, 00, 00); + Date reference = Timestamp.valueOf(refDateTime); calendarSource = new CalendarSource(reference); validateDateTime(reference, "2011-06-17T07:00:00Z", 6, 17, 2011, 3, 0, 0); diff --git a/src/test/java/com/joestelmach/natty/grammar/AbstractGrammarTest.java b/src/test/java/org/natty/grammar/AbstractGrammarTest.java similarity index 82% rename from src/test/java/com/joestelmach/natty/grammar/AbstractGrammarTest.java rename to src/test/java/org/natty/grammar/AbstractGrammarTest.java index 1e3a69fc..65080d15 100644 --- a/src/test/java/com/joestelmach/natty/grammar/AbstractGrammarTest.java +++ b/src/test/java/org/natty/grammar/AbstractGrammarTest.java @@ -1,4 +1,4 @@ -package com.joestelmach.natty.grammar; +package org.natty.grammar; import java.io.ByteArrayInputStream; import java.lang.reflect.Method; @@ -12,11 +12,11 @@ import org.antlr.runtime.tree.CommonTreeNodeStream; import org.antlr.runtime.tree.Tree; -import com.joestelmach.natty.ANTLRNoCaseInputStream; -import com.joestelmach.natty.ParseListener; -import com.joestelmach.natty.generated.DateLexer; -import com.joestelmach.natty.generated.DateParser; -import com.joestelmach.natty.generated.TreeRewrite; +import org.natty.ANTLRNoCaseInputStream; +import org.natty.ParseListener; +import org.natty.generated.DateLexer; +import org.natty.generated.DateParser; +import org.natty.generated.TreeRewrite; public abstract class AbstractGrammarTest { protected String _ruleName; @@ -38,7 +38,7 @@ protected void assertAST(String input, String ast) throws Exception { */ protected String buildAST(String value) throws Exception { DateParser parser = buildParser(value); - Class klass = Class.forName("com.joestelmach.natty.generated.DateParser"); + Class klass = Class.forName("org.natty.generated.DateParser"); Method meth = klass.getMethod(_ruleName, (Class[]) null); ParserRuleReturnScope ret = (ParserRuleReturnScope) meth.invoke(parser, (Object[]) null); diff --git a/src/test/java/com/joestelmach/natty/grammar/DateGrammarTest.java b/src/test/java/org/natty/grammar/DateGrammarTest.java similarity index 99% rename from src/test/java/com/joestelmach/natty/grammar/DateGrammarTest.java rename to src/test/java/org/natty/grammar/DateGrammarTest.java index ebae82f9..c97b3466 100644 --- a/src/test/java/com/joestelmach/natty/grammar/DateGrammarTest.java +++ b/src/test/java/org/natty/grammar/DateGrammarTest.java @@ -1,4 +1,4 @@ -package com.joestelmach.natty.grammar; +package org.natty.grammar; import org.junit.Test; diff --git a/src/test/java/com/joestelmach/natty/grammar/DateTimeGrammarTest.java b/src/test/java/org/natty/grammar/DateTimeGrammarTest.java similarity index 99% rename from src/test/java/com/joestelmach/natty/grammar/DateTimeGrammarTest.java rename to src/test/java/org/natty/grammar/DateTimeGrammarTest.java index 49d09f97..734e1571 100644 --- a/src/test/java/com/joestelmach/natty/grammar/DateTimeGrammarTest.java +++ b/src/test/java/org/natty/grammar/DateTimeGrammarTest.java @@ -1,4 +1,4 @@ -package com.joestelmach.natty.grammar; +package org.natty.grammar; import org.junit.Test; diff --git a/src/test/java/com/joestelmach/natty/grammar/HolidayGrammarTest.java b/src/test/java/org/natty/grammar/HolidayGrammarTest.java similarity index 99% rename from src/test/java/com/joestelmach/natty/grammar/HolidayGrammarTest.java rename to src/test/java/org/natty/grammar/HolidayGrammarTest.java index fce221b4..083456ad 100644 --- a/src/test/java/com/joestelmach/natty/grammar/HolidayGrammarTest.java +++ b/src/test/java/org/natty/grammar/HolidayGrammarTest.java @@ -1,4 +1,4 @@ -package com.joestelmach.natty.grammar; +package org.natty.grammar; import org.junit.Test; diff --git a/src/test/java/com/joestelmach/natty/grammar/NumericGrammarTest.java b/src/test/java/org/natty/grammar/NumericGrammarTest.java similarity index 99% rename from src/test/java/com/joestelmach/natty/grammar/NumericGrammarTest.java rename to src/test/java/org/natty/grammar/NumericGrammarTest.java index 606dd15b..c81200bc 100644 --- a/src/test/java/com/joestelmach/natty/grammar/NumericGrammarTest.java +++ b/src/test/java/org/natty/grammar/NumericGrammarTest.java @@ -1,4 +1,4 @@ -package com.joestelmach.natty.grammar; +package org.natty.grammar; import org.junit.Test; diff --git a/src/test/java/com/joestelmach/natty/grammar/TimeGrammarTest.java b/src/test/java/org/natty/grammar/TimeGrammarTest.java similarity index 99% rename from src/test/java/com/joestelmach/natty/grammar/TimeGrammarTest.java rename to src/test/java/org/natty/grammar/TimeGrammarTest.java index b0eaba2f..12fb8545 100644 --- a/src/test/java/com/joestelmach/natty/grammar/TimeGrammarTest.java +++ b/src/test/java/org/natty/grammar/TimeGrammarTest.java @@ -1,4 +1,4 @@ -package com.joestelmach.natty.grammar; +package org.natty.grammar; import org.junit.Test; diff --git a/src/test/resources/logback-test.xml b/src/test/resources/logback-test.xml new file mode 100644 index 00000000..6779d7da --- /dev/null +++ b/src/test/resources/logback-test.xml @@ -0,0 +1,17 @@ + + + + + + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + \ No newline at end of file