pad 0 for single digit - Android java.lang

Android examples for java.lang:String Pad

Description

pad 0 for single digit

Demo Code

import android.content.Context;
import android.graphics.Color;
import java.text.DecimalFormat;

public class Main{

    public static String pad(int c) {
        if (c >= 10)
            return String.valueOf(c);
        else//from w ww . j ava 2 s. c  o m
            return "0" + String.valueOf(c);
    }

}

Related Tutorials