Is there a formatting flag that converts to a lowercase String in Java?

No, there is not. But, according to Java Docs:

Conversions denoted by an upper-case character (i.e. ‘B’, ‘H’, ‘S’, ‘C’, ‘X’, ‘E’, ‘G’, ‘A’, and ‘T’) are the same as those for the corresponding lower-case conversion characters except that the result is converted to upper case according to the rules of the prevailing Locale. The result is equivalent to the following invocation of String.toUpperCase()

In other words, the following

String result = String.format("%S", "Hi James!");

is equivalent to

String result = String.format("%s", "Hi James!").toUpperCase();

So, if you want to get a lower case string, you can just do:

String result = String.format("%s", "Hi James!").toLowerCase();

There won’t be an optimization by doing the conversion using a flag.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)