자바 zfill()

1 개요[ | ]

Java zfill()
자바 zfill()
public class MyClass {
    public static void main(String args[]) {
        int num = 83;
        System.out.println( String.format("%04d", num) );
        // 0083
    }
}
public class MyClass {
    public static void main(String args[]) {
        int num = 83;
        System.out.println( String.format("%04d", num) );
        // 0083
    }
}
public class MyClass {
    public static void main(String args[]) {
        String str = "83";
        System.out.println( String.format("%04d", Integer.parseInt(str)) );
        // 0083
    }
}
import org.apache.commons.lang3.StringUtils;
public class MyClass {
    public static void main(String args[]) {
        int num = 83;
        System.out.println( StringUtils.leftPad(String.valueOf(num), 4, "0") );
        // 0083
    }
}
import org.apache.commons.lang3.StringUtils;
public class MyClass {
    public static void main(String args[]) {
        String str = "83";
        System.out.println( StringUtils.leftPad(str, 4, "0") );
        // 0083
    }
}

2 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}