Example usage for java.lang Integer Integer

List of usage examples for java.lang Integer Integer

Introduction

In this page you can find the example usage for java.lang Integer Integer.

Prototype

@Deprecated(since = "9")
public Integer(String s) throws NumberFormatException 

Source Link

Document

Constructs a newly allocated Integer object that represents the int value indicated by the String parameter.

Usage

From source file:Main.java

public static byte[] shortToByte(short number) {
    int temp = number;
    byte[] b = new byte[2];
    for (int i = 0; i < b.length; i++) {
        b[i] = new Integer(temp & 0xff).byteValue();
        temp = temp >> 8;/*from   w  w w .  j ava 2s. c  o m*/
    }
    return b;
}

From source file:Main.java

public static byte[] shortToByte(short number) {
    int temp = number;
    byte[] b = new byte[2];
    for (int i = (b.length - 1); i >= 0; i--) {
        b[i] = new Integer(temp & 0xff).byteValue();
        temp = temp >> 8;/* w w  w  . ja va2  s  .  c o  m*/
    }
    return b;
}

From source file:Main.java

public static String getStringForColor(int c) {
    String result = (String) intToString.get(new Integer(c));
    if (result != null) {
        return result;
    }//from  w  ww .  j a v a2s  . co m
    return getHexForColor(c);
}

From source file:Main.java

public static byte[] shortToBytes(short number) {
    int temp = number;
    byte[] bytes = new byte[2];
    for (int i = 0; i < bytes.length; i++) {
        bytes[i] = new Integer(temp & 0xff).byteValue();
        temp = temp >> 8;/*from ww w  . j a  va  2s . c om*/
    }
    return bytes;
}

From source file:Main.java

public static int dateToInt(Date date) {
    String str = dateToIntString(date);
    return new Integer(str);
}

From source file:Main.java

public static byte[] float2bytes(float value) {
    byte[] result = new byte[4];
    int temp = Float.floatToIntBits(value);

    for (int i = 0; i < 4; i++) {
        result[i] = new Integer(temp).byteValue();
        temp = temp >> 8;/* w ww .j  a  v  a 2s .  c  om*/
    }

    return result;
}

From source file:Main.java

public static void putFloat(byte[] bb, float x, int index) {
    // byte[] b = new byte[4];
    int l = Float.floatToIntBits(x);
    for (int i = 0; i < 4; i++) {
        bb[index + i] = new Integer(l).byteValue();
        l = l >> 8;//from   ww  w . j a v  a 2  s  . c om
    }
}

From source file:Main.java

public static int getWeekOfYear(String year, String month, String day) {
    Calendar cal = new GregorianCalendar();
    cal.clear();// w w w .j  a  v  a  2  s .  co m
    cal.set(new Integer(year).intValue(), new Integer(month).intValue() - 1, new Integer(day).intValue());
    return cal.get(Calendar.WEEK_OF_YEAR);
}

From source file:Main.java

public static List<Integer> toCollection(int[] intIds) {
    List<Integer> integerIds = new ArrayList<Integer>();
    for (int intId : intIds) {
        integerIds.add(new Integer(intId));
    }//ww  w .java 2s.com
    return integerIds;
}

From source file:Main.java

static void add(int color, String name) {
    Integer c = new Integer(color);
    intToString.put(c, name);
    stringToInt.put(name, c);
}