BUG: Lucene.Net.Tests.QueryParser.Flexible.Standard.TestNumericQueryParser: corrected implementation to account for era, full year, timezone and second as in the original implementation.
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/f6f2ac09 Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/f6f2ac09 Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/f6f2ac09 Branch: refs/heads/api-work Commit: f6f2ac097ba066bccf7a53acc1b006ad46497c71 Parents: 33950f9 Author: Shad Storhaug <[email protected]> Authored: Wed Mar 8 16:52:26 2017 +0700 Committer: Shad Storhaug <[email protected]> Committed: Wed Mar 8 16:57:00 2017 +0700 ---------------------------------------------------------------------- .../Flexible/Standard/TestNumericQueryParser.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f6f2ac09/src/Lucene.Net.Tests.QueryParser/Flexible/Standard/TestNumericQueryParser.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Tests.QueryParser/Flexible/Standard/TestNumericQueryParser.cs b/src/Lucene.Net.Tests.QueryParser/Flexible/Standard/TestNumericQueryParser.cs index 601c1d0..83f4a3c 100644 --- a/src/Lucene.Net.Tests.QueryParser/Flexible/Standard/TestNumericQueryParser.cs +++ b/src/Lucene.Net.Tests.QueryParser/Flexible/Standard/TestNumericQueryParser.cs @@ -112,10 +112,18 @@ namespace Lucene.Net.QueryParsers.Flexible.Standard //dateFormat.applyPattern(dateFormat.toPattern() + " G s Z yyyy"); //dateFormat.setTimeZone(TIMEZONE); + // assumes localized date pattern will have at least year, month, day, + // hour, minute DATE_FORMAT = new NumberDateFormat(DATE_STYLE, TIME_STYLE, LOCALE) { TimeZone = TIMEZONE }; + + // not all date patterns includes era, full year, timezone and second, + // so we add them here + DATE_FORMAT.SetDateFormat(DATE_FORMAT.GetDateFormat() + " g s z yyyy"); + + dateFormat = DATE_FORMAT.GetDateFormat(); do @@ -451,7 +459,7 @@ namespace Lucene.Net.QueryParsers.Flexible.Standard // EscapeQuerySyntax.Type.STRING).toString(); lowerDateStr = ESCAPER.Escape( - DATE_FORMAT.Format(Convert.ToInt64(lowerDateNumber)), + DATE_FORMAT.Format(Convert.ToInt64(lowerDateNumber, CultureInfo.InvariantCulture)), LOCALE, EscapeQuerySyntaxType.STRING).toString(); } @@ -467,7 +475,7 @@ namespace Lucene.Net.QueryParsers.Flexible.Standard // EscapeQuerySyntax.Type.STRING).toString(); upperDateStr = ESCAPER.Escape( - DATE_FORMAT.Format(Convert.ToInt64(upperDateNumber)), + DATE_FORMAT.Format(Convert.ToInt64(upperDateNumber, CultureInfo.InvariantCulture)), LOCALE, EscapeQuerySyntaxType.STRING).toString(); }
