Sarankumar18 opened a new pull request, #1700:
URL: https://github.com/apache/commons-lang/pull/1700

   DurationFormatUtils.lexx() does not handle escaped single quotes, making it
   impossible to include a literal apostrophe in formatted duration output.
   
   The root cause is in the lexx() parser: when it encounters a single quote
   while inside a literal block, it unconditionally ends the literal. It never
   checks whether the next character is also a single quote, which should mean
   "emit a literal apostrophe and continue the literal."
   
   This behavior contradicts the quoting convention established by
   java.text.SimpleDateFormat, where '' consistently produces a literal
   single quote. The class Javadoc acknowledged the limitation explicitly:
   
       "Note: It's not currently possible to include a single-quote in a 
format."
   
   and a TODO in lexx() read:
   
       // TODO: Need to handle escaping of '
   
   This PR modifies lexx() to recognise '' as an escaped single quote — both
   inside and outside quoted literal sections — matching SimpleDateFormat
   behavior. The Javadoc has been updated to document the '' convention and
   the TODO has been removed.
   
   Note: This is a minor behavioral change. Existing format strings that relied
   on '' as "close one literal then open another" will now produce a literal
   apostrophe instead. This aligns with what most users would expect.
   
   This issue is tracked 
as[LANG-1827](https://issues.apache.org/jira/browse/LANG-1827).
   
   - [x] Read the contribution guidelines for this project.
   - [x] Read the ASF Generative Tooling Guidance.
   - [x] Ran a successful build with `mvn`.
   - [x] Unit tests cover all new behavior and verify no regressions.
   - [x] Commit message follows the [LANG-XXXX] convention.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to