Example usage for java.lang Integer valueOf

List of usage examples for java.lang Integer valueOf

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public static Integer valueOf(int i) 

Source Link

Document

Returns an Integer instance representing the specified int value.

Usage

From source file:Main.java

public static int readIntAttribute(XMLStreamReader reader, String attributeName) {
    return Integer.valueOf(reader.getAttributeValue(null, attributeName));
}

From source file:Main.java

/**
 * Get the cursor//ww w . j  a va  2s. c om
 * @param cursor Cursor from where read value
 * @param index int to read
 * @return Object read
 */
private static Object getCursorValue(Cursor cursor, int index) {
    switch (cursor.getType(index)) {
    case Cursor.FIELD_TYPE_INTEGER:
        return Integer.valueOf(cursor.getInt(index));
    case Cursor.FIELD_TYPE_FLOAT:
        return Float.valueOf(cursor.getFloat(index));
    case Cursor.FIELD_TYPE_STRING:
        return cursor.getString(index);
    case Cursor.FIELD_TYPE_BLOB:
        return cursor.getBlob(index);
    default:
        return null;
    }
}

From source file:Main.java

public static String timeFormatMillis(String millis) {
    try {/*from w ww .  ja  v a2  s.c o m*/
        int value = Integer.valueOf(millis);
        return timeFormatMillis(value);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}

From source file:Main.java

/**
 * compare two time by date ,ignore HH:mm:ss
 *
 * @param ltime//from   w w w . ja  v a 2  s .  c  o  m
 * @param rtime
 * @return
 */
public static int compareDay(long ltime, long rtime) {
    int lValue = Integer.valueOf(formatYYYYMMDD.format(new Date(ltime)));
    int rValue = Integer.valueOf(formatYYYYMMDD.format(new Date(rtime)));

    if (lValue > rValue) {//ascending by YYYYMMDD
        return 1;
    } else if (lValue < rValue) {
        return -1;
    } else {
        return 0;
    }
}

From source file:Main.java

public static List<Integer> asList(int[] a) {
    List<Integer> result = new ArrayList<Integer>(a.length);
    for (int i = 0; i < a.length; i++) {
        result.add(Integer.valueOf(a[i]));
    }//  w w  w  .jav a2 s.  co m
    return result;
}

From source file:Main.java

/**
 * Returns the integer value of the named attribute for the given node
 * If no such attribute exists, returns 0
 *//*from   w w  w.  j a  v  a 2s. c  om*/
public static int getIntValue(Node node, String name) {
    // Look for the attribute
    Node att = get_named_attribute(node, name);
    if (att != null) {
        // Return the value
        return Integer.valueOf(att.getNodeValue()).intValue();
    } else {
        // No such attribute
        return 0;
    }
}

From source file:Main.java

public static int[] parseIntList(String list) {
    if (list == null)
        return null;

    intMatch.reset(list);/*from   ww w  .j  a  v a2s .co  m*/

    LinkedList<Integer> intList = new LinkedList<Integer>();
    while (intMatch.find()) {
        String val = intMatch.group();
        intList.add(Integer.valueOf(val));
    }

    int[] retArr = new int[intList.size()];
    Iterator<Integer> it = intList.iterator();
    int idx = 0;
    while (it.hasNext()) {
        retArr[idx++] = ((Integer) it.next()).intValue();
    }

    return retArr;
}

From source file:Main.java

public static ArrayList<Integer> getOccupantsIdsListFromString(String occupantIds) {
    ArrayList<Integer> occupantIdsList = new ArrayList<Integer>();
    String[] occupantIdsArray = occupantIds.split(OCCUPANT_IDS_DIVIDER);
    for (String occupantId : occupantIdsArray) {
        occupantIdsList.add(Integer.valueOf(occupantId));
    }/*w w  w . j ava2 s  .  c  om*/
    return occupantIdsList;
}

From source file:Main.java

public static String getDate(String integer) {
    SimpleDateFormat sdf = new SimpleDateFormat("EEEE,MMMM d,yyyy h:mm,a", Locale.ENGLISH);
    sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
    String formattedDate = sdf.format(new Date());
    if (!integer.equalsIgnoreCase("null")) {
        long seconds = Integer.valueOf(integer);
        long millis = seconds * 1000;
        Date date = new Date(millis);
        formattedDate = sdf.format(date);
        return formattedDate;
    }/* w w w  .  ja v a  2s  .c om*/
    return formattedDate;

}

From source file:Main.java

private static BufferedImage getPooledImage(int width, int height, int index) {
    String key = String.format("%dx%d#%d",
            new Object[] { Integer.valueOf(width), Integer.valueOf(height), Integer.valueOf(index) });
    Reference ref = (Reference) imagePool.get(key);
    BufferedImage image = ref == null ? null : (BufferedImage) ref.get();

    if (image == null) {
        image = new BufferedImage(width, height, 2);
        imagePool.put(key, new SoftReference(image));
    }//from  www.  j  a  v a 2  s . c  o  m

    return image;
}