You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "theshoeshiner (via GitHub)" <gi...@apache.org> on 2023/07/05 11:19:36 UTC

[GitHub] [commons-lang] theshoeshiner commented on a diff in pull request #1062: Syntax for optional tokens in DurationFormatUtils

theshoeshiner commented on code in PR #1062:
URL: https://github.com/apache/commons-lang/pull/1062#discussion_r1252959306


##########
src/main/java/org/apache/commons/lang3/time/DurationFormatUtils.java:
##########
@@ -48,6 +48,13 @@
  * Token values are printed using decimal digits.
  * A token character can be repeated to ensure that the field occupies a certain minimum
  * size. Values will be left-padded with 0 unless padding is disabled in the method invocation.
+ * <br>
+ * Tokens can be marked as optional by surrounding them with brackets [ ]. These tokens will 
+ * only be printed if the token value is non-zero. Any literals within optional blocks will only be 
+ * printed if the nearest prior non-literal token value was non-zero.

Review Comment:
   Originally I could not come up with too many scenarios where a leading literal would make sense, but surrounding a token with brackets does seem like a reasonable use. I agree the simplest/best solution would be to use the first token. 



-- 
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: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org