[GitHub] commons-lang pull request #296: LANG-1355: Add FastTimeZone to decrease Time...

2017-10-08 Thread chonton
GitHub user chonton opened a pull request:

https://github.com/apache/commons-lang/pull/296

LANG-1355: Add FastTimeZone to decrease TimeZone.getTimezone latency

Adding FastTimeZone to decrease latency of timezone lookups.   I'll hold 
this PR open for 48 hours for commons committers' comments.  Thanks!

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/chonton/commons-lang LANG-1355

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/commons-lang/pull/296.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #296


commit a703646e949c277c5249c87e08486d2b7a69cb34
Author: Chas Honton 
Date:   2017-10-09T01:54:17Z

LANG-1355: Add FasTimeZone to decrease TimeZone.getTimezone latency

commit 7670979033076f354af7e4cf852709d5403ffbd4
Author: Chas Honton 
Date:   2017-10-09T02:18:01Z

Replace all TimeZone.getTimeZone(UTC) wiht FastTimeZone.getGmtTimeZone()




---


[GitHub] commons-lang pull request #296: LANG-1355: Add FastTimeZone to decrease Time...

2017-10-10 Thread chonton
Github user chonton commented on a diff in the pull request:

https://github.com/apache/commons-lang/pull/296#discussion_r143748823
  
--- Diff: src/main/java/org/apache/commons/lang3/time/FastTimeZone.java ---
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.lang3.time;
+
+import java.util.TimeZone;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Faster methods to produce custom time zones.
+ *
+ * @since 3.7
+ */
+public class FastTimeZone {
--- End diff --

done


---


[GitHub] commons-lang pull request #296: LANG-1355: Add FastTimeZone to decrease Time...

2017-10-10 Thread chonton
Github user chonton commented on a diff in the pull request:

https://github.com/apache/commons-lang/pull/296#discussion_r143748869
  
--- Diff: src/main/java/org/apache/commons/lang3/time/FastTimeZone.java ---
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.lang3.time;
+
+import java.util.TimeZone;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Faster methods to produce custom time zones.
+ *
+ * @since 3.7
+ */
+public class FastTimeZone {
+
+private static final TimeZone GREENWICH = new GmtTimeZone(false, 0, 0);
+
+/**
+ * Get the GMT TimeZone.
+ * @return A TimeZone with a raw offset of zero.
+ */
+public static TimeZone getGmtTimeZone() {
+return GREENWICH;
+}
+
+/**
+ * Get a TimeZone, looking first for GMT custom ids, then falling back 
to Olson ids.
+ * A GMT custom id has an optional prefix of GMT, followed by sign, 
hours digit(s), optional
+ * colon(':'), and optional minutes digits: [GMT] (+|-) Hours [[:] 
Minutes]
+ *
+ * @param id A GMT custom id or Olsen id
+ * @return A timezone
+ */
+public static TimeZone getTimeZone(String id) {
+TimeZone tz = getGmtTimeZone(id);
+if (tz != null) {
+return tz;
+}
+return TimeZone.getTimeZone(id);
+}
+
+private static final Pattern GMT_PATTERN = 
Pattern.compile("^(?:(?i)GMT)?([+-])?(\\d\\d?)?(:?(\\d\\d?))?$");
+
+/**
+ * Get a TimeZone with GMT offsets.  A GMT offset must be either 'Z' 
or match
+ * (GMT)? hh?(:?mm?)?, where h and m are digits representing hours and 
minutes.
--- End diff --

done


---


[GitHub] commons-lang pull request #296: LANG-1355: Add FastTimeZone to decrease Time...

2017-10-10 Thread chonton
Github user chonton commented on a diff in the pull request:

https://github.com/apache/commons-lang/pull/296#discussion_r143748954
  
--- Diff: src/main/java/org/apache/commons/lang3/time/GmtTimeZone.java ---
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.lang3.time;
+
+import java.util.Date;
+import java.util.TimeZone;
+
+/**
+ * Custom timezone that contains offset from GMT.
+ *
+ * @since 3.7
+ */
+class GmtTimeZone extends TimeZone {
--- End diff --

great catch! done


---


[GitHub] commons-lang pull request #296: LANG-1355: Add FastTimeZone to decrease Time...

2017-10-10 Thread chonton
Github user chonton commented on a diff in the pull request:

https://github.com/apache/commons-lang/pull/296#discussion_r143749105
  
--- Diff: src/test/java/org/apache/commons/lang3/time/GmtTimeZoneTest.java 
---
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.lang3.time;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Tests for GmtTimeZone
+ */
+public class GmtTimeZoneTest {
+
+@Test(expected = IllegalArgumentException.class)
+public void hoursOutOfRange() {
+new GmtTimeZone(false, 24, 0);
+}
+
+@Test
+public void hoursInRange() {
+Assert.assertEquals(23 * 60 * 60 * 1000, new GmtTimeZone(false, 
23, 0).getRawOffset());
+}
+
+@Test(expected = IllegalArgumentException.class)
+public void minutesOutOfRange() {
+Assert.assertEquals(0, new GmtTimeZone(false, 60, 0));
--- End diff --

great catch! thanks.
done.


---


[GitHub] commons-lang pull request #296: LANG-1355: Add FastTimeZone to decrease Time...

2017-10-10 Thread chonton
Github user chonton commented on a diff in the pull request:

https://github.com/apache/commons-lang/pull/296#discussion_r143749142
  
--- Diff: src/test/java/org/apache/commons/lang3/time/GmtTimeZoneTest.java 
---
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.lang3.time;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Tests for GmtTimeZone
+ */
+public class GmtTimeZoneTest {
+
+@Test(expected = IllegalArgumentException.class)
+public void hoursOutOfRange() {
+new GmtTimeZone(false, 24, 0);
+}
+
+@Test
+public void hoursInRange() {
+Assert.assertEquals(23 * 60 * 60 * 1000, new GmtTimeZone(false, 
23, 0).getRawOffset());
+}
+
+@Test(expected = IllegalArgumentException.class)
+public void minutesOutOfRange() {
+Assert.assertEquals(0, new GmtTimeZone(false, 60, 0));
+}
+
+@Test
+public void minutesInRange() {
+Assert.assertEquals(59 * 60 * 1000, new GmtTimeZone(false, 0, 
59).getRawOffset());
+}
+
+@Test
+public void getOffset() {
+Assert.assertEquals(0, new GmtTimeZone(false, 0, 
0).getOffset(234304));
+}
+
+@Test(expected = UnsupportedOperationException.class)
+public void setRawOffset() {
+new GmtTimeZone(false, 0, 0).setRawOffset(0);
+}
+
+@Test
+public void getRawOffset() {
+Assert.assertEquals(0, new GmtTimeZone(false, 0, 
0).getRawOffset());
+}
+
+@Test
+public void getID() {
+Assert.assertEquals("GMT+00:00", new GmtTimeZone(false, 0, 
0).getID());
+Assert.assertEquals("GMT+01:02", new GmtTimeZone(false, 1, 
2).getID());
+Assert.assertEquals("GMT+11:22", new GmtTimeZone(false, 11, 
22).getID());
+Assert.assertEquals("GMT-01:02", new GmtTimeZone(true, 1, 
2).getID());
+Assert.assertEquals("GMT-11:22", new GmtTimeZone(true, 11, 
22).getID());
+}
+
+@Test
+public void useDaylightTime() {
+Assert.assertFalse(new GmtTimeZone(false, 0, 0).useDaylightTime());
+}
+
+@Test
+public void inDaylightTime() {
+Assert.assertFalse(new GmtTimeZone(false, 0, 0).useDaylightTime());
+}
--- End diff --

done


---


[GitHub] commons-lang pull request #331: LANG-1380: FastDateParser too strict on abbr...

2018-05-18 Thread chonton
GitHub user chonton opened a pull request:

https://github.com/apache/commons-lang/pull/331

LANG-1380: FastDateParser too strict on abbreviated short month symbols

I'm interested in feedback.  Particularly from recent committers - 
@garydgregory @britter @PascalSchumacher @sebbASF 
thanks


You can merge this pull request into a Git repository by running:

$ git pull https://github.com/chonton/commons-lang LANG-1380

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/commons-lang/pull/331.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #331


commit 8c114fa865156fa4341390e66e42ca0cf3c494c8
Author: Chas Honton 
Date:   2018-05-19T01:29:26Z

LANG-1380: FastDateParser too strict on abbreviated short month symbols




---


[GitHub] commons-lang issue #331: LANG-1380: FastDateParser too strict on abbreviated...

2018-07-02 Thread chonton
Github user chonton commented on the issue:

https://github.com/apache/commons-lang/pull/331
  
closed with commit f56931c176fef5e164b681c740746aebdec3


---


[GitHub] commons-lang pull request #331: LANG-1380: FastDateParser too strict on abbr...

2018-07-02 Thread chonton
Github user chonton closed the pull request at:

https://github.com/apache/commons-lang/pull/331


---


[GitHub] commons-lang pull request: LANG-1127: Use JUnit rules to set and r...

2015-05-04 Thread chonton
Github user chonton commented on the pull request:

https://github.com/apache/commons-lang/pull/76#issuecomment-9878
  
Overall, I like this approach better than explicit classes.  Two items I 
would like to see:
1. Allow tests to run in parallel.  This will probably requires some sort 
of synchronization to allow only one tests at a time to change default TimeZone 
or Locale.
2. Apply the rule to individual test methods instead of to all methods in a 
test class.  Perhaps this could be done by creating annotation(s) which enable 
the Rule.  I am thinking of something like SwitchDefaults(locale="locale_name", 
timezone="timezone_name").


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] commons-lang pull request: LANG-1127: Use JUnit rules to set and r...

2015-05-07 Thread chonton
Github user chonton commented on the pull request:

https://github.com/apache/commons-lang/pull/76#issuecomment-12112
  
Iterate fast and often. Go forward with it. 

Chas

> On May 7, 2015, at 12:17 PM, Benedikt Ritter  
wrote:
> 
    > @chonton I've worked some more on this. Renamed the Rule to 
SystemDefaultsSwitch and wrote a unit test. What do you think about integrating 
this now and create a new PR for the synchronization?
> 
> ―
> Reply to this email directly or view it on GitHub.
> 



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] commons-lang pull request: refactor FastDateParser

2015-06-11 Thread chonton
GitHub user chonton opened a pull request:

https://github.com/apache/commons-lang/pull/96

refactor FastDateParser

use hashmap for performance
break down regular expressions to per-format, allowing
ParsePosition to get set
add parse with Calendar input, allowing client to set leniency
and/or replace display names

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/chonton/commons-lang refactor-fastdateparser

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/commons-lang/pull/96.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #96


commit 94faa31bcf5c4fcb20818a3a0d23ae789932d2df
Author: Chas Honton 
Date:   2015-06-12T03:07:13Z

refactor FastDateParser

use hashmap for performance
break down regular expressions to per-format, allowing
ParsePosition to get set
add parse with Calendar input, allowing client to set leniency
and/or replace display names




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] commons-lang pull request: Ability to throw checked exceptions wit...

2015-07-12 Thread chonton
Github user chonton commented on the pull request:

https://github.com/apache/commons-lang/pull/98#issuecomment-120771432
  
Refactored and committed.  See 
https://github.com/apache/commons-lang/commit/59022fb870c2c45a27e00943003c5acdeddaeec3
 and 
https://github.com/apache/commons-lang/commit/03fe88ab71cf2eadaa39654786c3fba713742768


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] commons-lang pull request: Replace string

2015-07-14 Thread chonton
Github user chonton commented on the pull request:

https://github.com/apache/commons-lang/pull/36#issuecomment-121482228
  
Most changes were committed in 
https://github.com/apache/commons-lang/commit/cc1aed9bdf196403c673a886bbf723101171a9bf
 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] commons-lang pull request: [LANG-903] Trunk - ToStringStyle typos ...

2016-04-23 Thread chonton
Github user chonton commented on the pull request:

https://github.com/apache/commons-lang/pull/7#issuecomment-213859284
  
The values are not xml escaped.  This won't be needed for class or field 
names.

If you're still interested, please update pull request against latest 
master branch.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] commons-lang pull request: fix LANG-1151

2016-04-23 Thread chonton
Github user chonton commented on the pull request:

https://github.com/apache/commons-lang/pull/99#issuecomment-213878630
  
Please update to resolve conflicts.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] commons-lang pull request: Adding to StringUtils truncate method a...

2016-04-23 Thread chonton
Github user chonton commented on the pull request:

https://github.com/apache/commons-lang/pull/24#issuecomment-213878951
  
Please update to resolve conflicts.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] commons-lang pull request: LANG-1065 Added new 'merge' method to D...

2016-04-23 Thread chonton
Github user chonton commented on the pull request:

https://github.com/apache/commons-lang/pull/39#issuecomment-213879073
  
Please update to resolve conflicts.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] commons-lang pull request: Adding unwrap and unwrapFull methods to...

2016-04-23 Thread chonton
Github user chonton commented on the pull request:

https://github.com/apache/commons-lang/pull/25#issuecomment-213879014
  
Please update to resolve conflicts.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] commons-lang pull request: [LANG-1120] Bugfix: StringUtils#stripAc...

2016-04-23 Thread chonton
Github user chonton commented on the pull request:

https://github.com/apache/commons-lang/pull/105#issuecomment-213879732
  
Patch does not apply.  Please update pull request.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] commons-lang pull request #165: update javadoc for DateParser and DatePrinte...

2016-06-12 Thread chonton
GitHub user chonton opened a pull request:

https://github.com/apache/commons-lang/pull/165

update javadoc for DateParser and DatePrinter



You can merge this pull request into a Git repository by running:

$ git pull https://github.com/chonton/commons-lang master

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/commons-lang/pull/165.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #165


commit 4b91070a2a118e3a8207561487acb55fc8a60ae2
Author: Chas Honton 
Date:   2016-06-13T00:34:33Z

update javadoc for DateParser and DatePrinter




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] commons-lang pull request #165: update javadoc for DateParser and DatePrinte...

2016-06-13 Thread chonton
Github user chonton closed the pull request at:

https://github.com/apache/commons-lang/pull/165


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] commons-lang issue #169: LANG-1248 FastDatePrinter Memory allocation regress...

2016-07-10 Thread chonton
Github user chonton commented on the issue:

https://github.com/apache/commons-lang/pull/169
  
Are you OK with using this [alternative 
implementation](https://github.com/chonton/commons-lang/commit/4d26fa6c107636c0f986c45379edcb18ac1ec3f5)?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---