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 long formatTimeString(String timeString) {
    long time = 0;
    if (timeString == null || timeString.length() < 1) {
        return time;
    }//from   w ww .ja v  a2  s  .  com
    try {
        String[] array = timeString.split(DASH);
        int year = Integer.valueOf(array[0]);
        int month = Integer.valueOf(array[1]);
        int day = Integer.valueOf(array[2]);

        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.YEAR, year);
        calendar.set(Calendar.MONTH, month);
        calendar.set(Calendar.DAY_OF_MONTH, day);

        time = calendar.getTimeInMillis();

    } catch (Exception e) {
        e.printStackTrace();
    }

    return time;
}

From source file:Main.java

public final static <GOutput> List<GOutput> toOrderedList(final Map<Integer, GOutput> responseMap) {
    final List<GOutput> localResponses = new ArrayList<GOutput>(responseMap.size());
    for (int i = 0; i < responseMap.size(); i++) {
        final GOutput rr = responseMap.get(Integer.valueOf(i));

        assert rr != null;

        localResponses.add(rr);//  w w  w.j  a v  a  2 s.c o m
    }
    return localResponses;
}

From source file:Main.java

public static Set<Integer> getNumsFromStr(String text) {
    text = null == text ? "" : text;
    String[] ary = text.replaceAll("[^\\d]", " ").split("\\s+");
    Set<Integer> set = new TreeSet<Integer>();
    for (String num : ary) {
        if (!num.trim().equals("")) {
            set.add(Integer.valueOf(num.trim()));
        }//from  w  w w  .  jav  a 2s .  co  m
    }
    return set;
}

From source file:Main.java

public static String formatDuration(String duration) {
    int miliSeconds = Integer.valueOf(duration);
    return formatDuration(miliSeconds);
}

From source file:Main.java

/**
 * // ww w . j ava  2  s  .  co  m
 * @param date
 * @return
 */
public static Date getDate(String date) {

    if ("".equals(date) || date == null || "null".equals(date)) {
        return null;
    } else {
        String[] obj = date.split("-");
        int year = Integer.valueOf((String) obj[0]).intValue();
        int month = Integer.valueOf((String) obj[1]).intValue();
        int day = Integer.valueOf((String) obj[2]).intValue();
        Calendar calendar = new GregorianCalendar(year, month - 1, day);
        return calendar.getTime();
    }
}

From source file:Main.java

public static void setCurrentPage(String key, int currentPage) {
    hmPages.put(key, Integer.valueOf(currentPage));
}

From source file:Main.java

public static Bitmap decodeResourcesBitmap(Context paramContext, int paramInt) {
    boolean bool = RESOURCES_BITMAP_CACHE.containsKey(Integer.valueOf(paramInt));
    Bitmap localBitmap = null;/* w  ww  .  ja  v a2  s. c  om*/
    if (bool) {
        localBitmap = (Bitmap) RESOURCES_BITMAP_CACHE.get(Integer.valueOf(paramInt));
    }
    if ((localBitmap == null) || (localBitmap.isRecycled())) {
        localBitmap = BitmapFactory.decodeStream(paramContext.getResources().openRawResource(paramInt));
        RESOURCES_BITMAP_CACHE.put(Integer.valueOf(paramInt), localBitmap);
    }
    return localBitmap;
}

From source file:Main.java

public static String normalizeTime(String militaryTime) {
    String[] timeBrokenUp = militaryTime.split(":");
    // 1 = HRS/*  www . jav a  2 s.c o m*/
    // 2 = MINS
    // 3 = SECONDS
    // we only want hrs and mins and have hrs in normal time
    String HR = timeBrokenUp[0];
    String MIN = timeBrokenUp[1];
    String AMorPM = "AM";
    int valueOfHR = Integer.valueOf(HR);
    // so we are deaing with military time
    if (Integer.valueOf(HR) > 12) {
        valueOfHR = valueOfHR - 12;
        AMorPM = "PM";
    }
    HR = String.valueOf(valueOfHR);

    militaryTime = HR + ":" + MIN + " " + AMorPM;

    return militaryTime;
}

From source file:Main.java

/**
 * Takes a string of the form [HH:]MM:SS[.mmm] and converts it to
 * milliseconds.//from   www.  j a va2  s  .  c  o  m
 */
public static long parseTimeString(final String time) {
    String[] parts = time.split(":");
    long result = 0;
    int idx = 0;
    if (parts.length == 3) {
        // string has hours
        result += Integer.valueOf(parts[idx]) * 3600000L;
        idx++;
    }
    result += Integer.valueOf(parts[idx]) * 60000L;
    idx++;
    result += (Float.valueOf(parts[idx])) * 1000L;
    return result;
}

From source file:Main.java

/**
 * Takes a string of the form [HH:]MM:SS[.mmm] and converts it to
 * milliseconds.//from  w w w. j a va2  s. co m
 */
public static long parseTimeString(final String time) {
    String[] parts = time.split(":");
    long result = 0;
    int idx = 0;
    if (parts.length == 3) {
        // string has hours
        result += Integer.valueOf(parts[idx]) * 3600000;
        idx++;
    }
    result += Integer.valueOf(parts[idx]) * 60000;
    idx++;
    result += (Float.valueOf(parts[idx])) * 1000;
    return result;
}