Java - Write code to pad string from Left using String.format

Requirements

Write code to pad string from Left using String.format

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String s = "book2s.com";
        int n = 42;
        System.out.println(padLeft(s, n));
    }/*  ww  w. j a  v a 2s.  c  o m*/

    public static String padLeft(String s, int n) {
        return String.format("%1$" + n + "s", s);
    }
}