Padding Int value : Integer « Date Type « Android






Padding Int value

    

/*
 * Copyright (C) 2009 Andago Ingenieria
 * Author: Alvaro del Castillo, adelcastillo@andago.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

//package es.acsblog;

class Util {
    public static String pad(int c) {
        if (c >= 10)
            return String.valueOf(c);
        else
            return "0" + String.valueOf(c);
    }
}

   
    
    
    
  








Related examples in the same category

1.Integer To One Byte
2.Integer To Two Bytes
3.Integer To Four Bytes
4.One Byte To Integer
5.Two Bytes To Integer
6.List to int[]
7.Tests if an integer is power of two
8.Convert an integer value to its byte array representation
9.Convert a byte array integer (4 bytes) to its int value
10.Convert a byte array representing an unsigned integer (4bytes) to its long value
11.fahrenheit To Celsius, celsius To Fahrenheit