[ 
https://issues.apache.org/jira/browse/LANG-1827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18088252#comment-18088252
 ] 

Sarankumar Baskar edited comment on LANG-1827 at 6/11/26 1:09 PM:
------------------------------------------------------------------

[~ggregory] 

Yes, I have a PR ready that fixes the behavior:

[#https://github.com/apache/commons-lang/pull/1700]

 

 


was (Author: JIRAUSER309304):
PR Link [https://github.com/apache/commons-lang/pull/1700/changes] for the 
improvement story

> "DurationFormatUtils.lexx() does not support escaped single quotes ('' should 
> produce literal ')"
> -------------------------------------------------------------------------------------------------
>
>                 Key: LANG-1827
>                 URL: https://issues.apache.org/jira/browse/LANG-1827
>             Project: Commons Lang
>          Issue Type: Improvement
>            Reporter: Sarankumar Baskar
>            Priority: Major
>
> *DurationFormatUtils.class* uses single quotes to delimit literal text in 
> format
> patterns, e.g. "H' hours 'm' minutes'" → "2 hours 30 minutes".
>  
> However, there is currently no way to include a literal single-quote
> (apostrophe) character in the output. The class Javadoc explicitly states:
>  
> "Note: It's not currently possible to include a single-quote in a format."
>  
> and there is a TODO comment in the lexx() parser method (line 672):
>  
> // TODO: Need to handle escaping of '
>  
> java.text.SimpleDateFormat solves this by treating two consecutive single
> quotes ('') as an escaped literal apostrophe — both inside and outside
> quoted sections. DurationFormatUtils should follow the same convention
> for consistency with the JDK and user expectations.
>  
> {*}Current behavior{*}:
> Format: "H' o''clock'"
> Expected: "2 o'clock"
> Actual: "2 oclock" (apostrophe is silently dropped)
>  
> Format: "'it''s 'H' hours'"
> Expected: "it's 2 hours"
> Actual: "its 2 hours" (apostrophe is silently dropped)
>  
> Format: "H'''h'"
> Expected: "2'h"
> Actual: "2h" (apostrophe is silently dropped)



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to