printfスタイルのフォーマットを使用してフォーマットされた文字列を返します。
構文
date.format(DateTimeFormatter.ofPattern(pattern))使用例
下記の値を入力するとサンプルに即時反映されます。
String→name→result→System→out→println→String name = "Alice";
int age = 30;
String result = String.format("이름: %s, 나이: %d", name, age);
System.out.println(result); // "이름: Alice, 나이: 30"