List of usage examples for java.lang String valueOf
public static String valueOf(double d)
From source file:Main.java
/** * parse value to short// w w w . ja v a 2 s .co m */ public static short toShort(Object value) { if (value instanceof Number) { return ((Number) value).shortValue(); } return value == null ? 0 : toShort(String.valueOf(value)); }
From source file:com.linkedin.pinot.common.config.AbstractTableConfig.java
public static AbstractTableConfig init(String jsonString) throws JSONException, IOException { JSONObject tableJson = new JSONObject(jsonString); String tableType = tableJson.getString("tableType").toLowerCase(); String tableName = new TableNameBuilder(TableType.valueOf(tableType.toUpperCase())) .forTable(tableJson.getString("tableName")); SegmentsValidationAndRetentionConfig validationConfig = loadSegmentsConfig( new ObjectMapper().readTree(tableJson.getJSONObject("segmentsConfig").toString())); TenantConfig tenantConfig = loadTenantsConfig( new ObjectMapper().readTree(tableJson.getJSONObject("tenants").toString())); TableCustomConfig customConfig = loadCustomConfig( new ObjectMapper().readTree(tableJson.getJSONObject("metadata").toString())); IndexingConfig indexingConfig = loadIndexingConfig( new ObjectMapper().readTree(tableJson.getJSONObject("tableIndexConfig").toString())); QuotaConfig quotaConfig = null;//from w w w . j a v a 2 s .c om if (tableJson.has(QuotaConfig.QUOTA_SECTION_NAME)) { try { quotaConfig = loadQuotaConfig(new ObjectMapper() .readTree(tableJson.getJSONObject(QuotaConfig.QUOTA_SECTION_NAME).toString())); } catch (ConfigurationRuntimeException e) { LOGGER.error("Invalid quota configuration value for table: {}", tableName); throw e; } } if (tableType.equals("offline")) { return new OfflineTableConfig(tableName, tableType, validationConfig, tenantConfig, customConfig, indexingConfig, quotaConfig); } else if (tableType.equals(TABLE_TYPE_REALTIME)) { return new RealtimeTableConfig(tableName, tableType, validationConfig, tenantConfig, customConfig, indexingConfig, quotaConfig); } throw new UnsupportedOperationException("unknown tableType : " + tableType); }
From source file:Main.java
public static String addPrefix(int num, String prefix) { return num < 10 ? prefix + num : String.valueOf(num); }
From source file:Main.java
public static String transferTP(String oldValue) { String newValue = oldValue;/* w ww. java 2s .com*/ float ov = Float.valueOf(oldValue) / 1000; Formatter fmt = new Formatter(); if (ov >= 100) { newValue = String.valueOf(Math.floor(ov + 0.5)); } else if (ov > 10) { newValue = fmt.format("%.1f", ov).toString(); } else { newValue = fmt.format("%.2f", ov).toString(); } return newValue; }
From source file:Main.java
public static String calculateAverage(int sum, int count) { int temp = sum; int countI = count; if (temp == 0 || countI == 0) return "0"; temp = temp / countI;//from w w w . j av a 2 s.co m return setPoint(String.valueOf(temp)); }
From source file:Main.java
/** * parse value to double/* w ww . j a v a2 s .c om*/ */ public static double toDouble(Object value) { if (value instanceof Number) { return ((Number) value).doubleValue(); } return value == null ? 0 : toDouble(String.valueOf(value)); }
From source file:Main.java
public static String getDefaultUsername(Context ctx) { TelephonyManager telephonyManager = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE); String did = telephonyManager.getDeviceId(); return String.valueOf(did); }
From source file:Main.java
public static String getFormattedTime(String time) { SimpleDateFormat sdfDate = new SimpleDateFormat("dd-MM-yyyy HH:mm", Locale.ENGLISH); String strDate = null;/*from w w w .ja va 2 s . co m*/ try { strDate = String.valueOf(sdfDate.parse(time)); } catch (ParseException e) { e.printStackTrace(); strDate = ""; } return strDate; }
From source file:Main.java
public static String indefinite(String s, int qty) { if (qty == 1) { if ("AEIOUYaeiouy".contains(s.substring(0, 1))) return "an " + s; else/*ww w .j a va2s . co m*/ return "a " + s; } else { return String.valueOf(qty) + " " + plural(s); } }
From source file:Main.java
public static String getLastText(String text) { if (text == null) { return null; }//w ww .j a va 2s . c om for (int i = text.length() - 1; i >= 0; --i) { int j = text.charAt(i); if ((j >= 19968) && (j <= 40869)) { return String.valueOf(j); } } return null; }