List of usage examples for java.lang Integer toString
@HotSpotIntrinsicCandidate public static String toString(int i)
From source file:Main.java
public static String print(int[] in) { StringBuilder ret = new StringBuilder(); ret.append("["); boolean isFirst = true; for (int t : in) { if (!isFirst) ret.append(", "); ret.append(Integer.toString(t)); isFirst = false;//from w w w.j av a 2 s . c o m } ret.append("]"); return ret.toString(); }
From source file:Main.java
/** * Adds a new element containing a CDATA section with the specified value to the parent element. * @param parent the parent element to add the new element to * @param namespaceURI the namespace of the added element's tag name, or null if there isn't any.. * @param tag the tag name of the new element * @param value the value to store in the CDATA section of the new element *///from w ww .j a va2s . c o m public static void addIntegerElementNS(Element parent, String namespaceURI, String tag, int value) { addTextElementNS(parent, namespaceURI, tag, Integer.toString(value)); }
From source file:de.bmarwell.j9kwsolver.util.BooleanUtils10.java
/** * Returns a textual representation of 1 for true or 0 for false. * @param bool - a boolean.//from www . j a v a 2s.com * @return either 0 or 1. */ public static String toIntegerString(final boolean bool) { int boolint = BooleanUtils.toInteger(bool); return Integer.toString(boolint); }
From source file:Main.java
public static String getFirstRevisionId() { String digest = createUUID(); return Integer.toString(1) + "-" + digest; }
From source file:Main.java
/** * Check the format of the firmware file name: 00-00-00 * * @param fileVerName is the firmware version formed into file name. * @return true, if the firmware name conforms to the rules. *//*from ww w . j ava2s. co m*/ public static boolean checkFileName(String fileVerName) { String[] nameElementArr = fileVerName.split("\\-"); int versionSize = 8; int verInfoElementCnt = 3; int verInfoElementSize = 2; int maxVerNum = 99; if ((fileVerName.length() == versionSize) && (nameElementArr.length == verInfoElementCnt)) { for (int i = 0; i < verInfoElementCnt; i++) { for (int j = 0; j <= maxVerNum; j++) { String number = Integer.toString(j); if ((j < 10) && (nameElementArr[i].equals("0" + number)) && (i == verInfoElementSize)) { return true; } else if (nameElementArr[i].equals(number) && (i == verInfoElementSize)) { return true; } } } } return false; }
From source file:Main.java
public static String calculateAge(Context context, String date) { final String FACEBOOK = "MM/dd/yyyy"; try {// w w w . j ava 2s .com SimpleDateFormat sf = new SimpleDateFormat(FACEBOOK, Locale.ENGLISH); sf.setLenient(true); Date birthDate = sf.parse(date); Date now = new Date(); int age = now.getYear() - birthDate.getYear(); birthDate.setHours(0); birthDate.setMinutes(0); birthDate.setSeconds(0); birthDate.setYear(now.getYear()); if (birthDate.after(now)) { age -= 1; } return Integer.toString(age); } catch (Exception e) { Log.d("DEBUG", "exception in getTwitterDate:"); e.printStackTrace(); return "Unknown"; } }
From source file:Main.java
public static void writeIntAttribute(XmlSerializer out, String name, int value) throws IOException { out.attribute(null, name, Integer.toString(value)); }
From source file:Main.java
public static SSLSocketFactory setCertificates(InputStream... certificates) { try {/* ww w. j av a2 s . co m*/ CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509"); KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType()); keyStore.load(null); int index = 0; for (InputStream certificate : certificates) { String certificateAlias = Integer.toString(index++); keyStore.setCertificateEntry(certificateAlias, certificateFactory.generateCertificate(certificate)); try { if (certificate != null) certificate.close(); } catch (IOException e) { } } SSLContext sslContext = SSLContext.getInstance("TLS"); TrustManagerFactory trustManagerFactory = TrustManagerFactory .getInstance(TrustManagerFactory.getDefaultAlgorithm()); trustManagerFactory.init(keyStore); sslContext.init(null, trustManagerFactory.getTrustManagers(), new SecureRandom()); socketFactory = sslContext.getSocketFactory(); } catch (Exception e) { e.printStackTrace(); } return socketFactory; }
From source file:Main.java
public static void pretty(Document document, OutputStream outputStream, int indent) throws IOException { TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer = null; try {//from ww w. j av a2s .c om transformer = transformerFactory.newTransformer(); } catch (TransformerConfigurationException e) { throw new RuntimeException(e); } transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); if (indent > 0) { transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", Integer.toString(indent)); } Result result = new StreamResult(outputStream); Source source = new DOMSource(document); try { transformer.transform(source, result); } catch (TransformerException e) { throw new IOException(e); } }
From source file:Main.java
/** * Appends the middle part to the given uri builder and returns it * @param uriBuilder/*from ww w. j a v a2s.co m*/ * @param cityId * @return */ @NonNull private static Uri.Builder appendMiddleToUriBuilder(@NonNull Uri.Builder uriBuilder, long cityId) { uriBuilder.appendPath(PATH_FORECAST).appendPath(PATH_DAILY) .appendQueryParameter(QUERY_CITY_ID, Long.toString(cityId)) .appendQueryParameter(QUERY_COUNT, Integer.toString(QUERY_DAILY_FORECAST_COUNT)); return uriBuilder; }