List of usage examples for java.lang Float toString
public String toString()
From source file:Main.java
public static void main(String[] args) { Float fObj = new Float(10.25); String str = fObj.toString(); System.out.println(str);/* ww w .j a v a2 s .c o m*/ }
From source file:Main.java
public static void main(String[] args) { Float floatObject2 = Float.valueOf(1.1F); System.out.println(floatObject2.toString()); }
From source file:com.mmj.app.common.util.StringFormatter.java
/*** * ?Float0/*from ww w . j av a 2 s.c o m*/ * * @param f * @return */ public static String floatFormat(Float f) { if (f == null) { return 0 + ""; } String s = f.toString(); if (s.indexOf(".") > 0) { s = s.replaceAll("0+?$", "");// 0 s = s.replaceAll("[.]$", "");// ??. } return s; }
From source file:de.cismet.lagis.cidsmigtest.StandartTypToStringTester.java
/** * DOCUMENT ME!/*ww w. j a v a 2s . c o m*/ * * @param object DOCUMENT ME! * * @return DOCUMENT ME! */ public static String getStringOf(final Float object) { if (object == null) { return null; } else { return "(Float) " + object.toString(); } }
From source file:com.hotelbeds.hotelapimodel.auto.util.AssignUtils.java
public static String getString(final Float number) { return number != null ? number.toString() : null; }
From source file:com.github.jessemull.microflex.util.BigIntegerUtil.java
/** * Safely converts a number to a BigInteger. Loss of precision may occur. Throws * an arithmetic exception upon overflow. * @param Object object to parse//from ww w .j a v a 2s . co m * @return parsed object * @throws ArithmeticException on overflow */ public static BigInteger toBigInteger(Object obj) { /* Switch on class and convert to BigInteger */ String type = obj.getClass().getSimpleName(); BigInteger parsed; switch (type) { case "Byte": Byte by = (Byte) obj; parsed = new BigInteger(by.toString()); break; case "Short": Short sh = (Short) obj; parsed = new BigInteger(sh.toString()); break; case "Integer": Integer in = (Integer) obj; parsed = new BigInteger(in.toString()); break; case "Long": Long lo = (Long) obj; parsed = new BigInteger(lo.toString()); break; case "Float": Float fl = (Float) obj; parsed = new BigInteger(fl.toString()); break; case "BigInteger": parsed = (BigInteger) obj; break; case "BigDecimal": parsed = ((BigDecimal) obj).toBigInteger(); break; case "Double": Double db = (Double) obj; parsed = new BigInteger(db.toString()); break; default: throw new IllegalArgumentException( "Invalid type: " + type + "\nData values " + "must extend the abstract Number class."); } return parsed; }
From source file:com.github.jessemull.microflex.util.BigIntegerUtil.java
/** * Safely converts a number to a BigInteger. Loss of precision may occur. Throws * an arithmetic exception upon overflow. * @param Number object to parse/* ww w .j av a 2 s. co m*/ * @return parsed object * @throws ArithmeticException on overflow */ public static BigInteger toBigInteger(Number number) { /* Switch on class and convert to BigInteger */ String type = number.getClass().getSimpleName(); BigInteger parsed; switch (type) { case "Byte": Byte by = (Byte) number; parsed = new BigInteger(by.toString()); break; case "Short": Short sh = (Short) number; parsed = new BigInteger(sh.toString()); break; case "Integer": Integer in = (Integer) number; parsed = new BigInteger(in.toString()); break; case "Long": Long lo = (Long) number; parsed = new BigInteger(lo.toString()); break; case "Float": Float fl = (Float) number; parsed = new BigInteger(fl.toString()); break; case "BigInteger": parsed = (BigInteger) number; break; case "BigDecimal": parsed = ((BigDecimal) number).toBigInteger(); break; case "Double": Double db = (Double) number; parsed = new BigInteger(db.toString()); break; default: throw new IllegalArgumentException( "Invalid type: " + type + "\nData values " + "must extend the abstract Number class."); } return parsed; }
From source file:org.modelibra.util.Transformer.java
/** * Transforms a Float object into a String object. * /*from w ww . j ava 2 s.c om*/ * @param floatObject * Float object * @return String object */ public static String string(Float floatObject) { try { return floatObject.toString(); } catch (NullPointerException e) { throw new TypeRuntimeException(e); } }
From source file:airlift.util.AirliftUtil.java
/** * Converts a float to byte array.//from w w w . j a v a2s . c om * * @param _number the _number * @return the byte[] */ public static byte[] convert(java.lang.Float _number) { return (_number == null) ? null : convert(_number.toString()); }
From source file:iddb.core.util.Functions.java
public static String minutes2Str(Long minutes) { Float num; String suffix = ""; if (minutes < 60) { num = new Float(minutes); } else if (minutes < 1440) { num = Float.valueOf(minutes) / 60; suffix = "h"; } else if (minutes < 10080) { num = Float.valueOf(minutes) / 1440; suffix = "d"; } else if (minutes < 525600) { num = Float.valueOf(minutes) / 10080; suffix = "w"; } else {//from www . j a va 2 s .c o m num = Float.valueOf(minutes) / 525600; suffix = "y"; } if ("0".equals(num.toString().substring(num.toString().indexOf(".") + 1))) { return String.format("%d%s", num.intValue(), suffix); } return String.format("%.2g%s", num, suffix); // 2=1 decimal }