Skip to content

Support more complex String.format rewrites #6

@niloc132

Description

@niloc132

https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/Formatter.html#syntax

%[argument_index$][flags][width][.precision]conversion

This will be a multi-part issue, will address them on an as needed basis. The baseline %<conversion> is already supported (just as the default tostring for each type), leaving <argumentIndex>$, <flags>, <width>, and .<precision>, and any extra handling for types.

  • argumentIndex support, so arg order is correct
  • width for integers - using the example String.format(Locale.US, ".%09d", nanos) from grpc-java - this requires the int/long value be written with a minimum of 9 characters
  • flag 0, using the same .%09d - the result will be zero padded
  • conversion B/b - null should be false.
  • conversion % - write the literal %

...

Items above should be converted into tickets as they are going to be addressed, new items added (make a comment below if you want something added here).

At this time, Locale will continue to not be supported, and will be removed from the expression.

Sub-issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions