/** Place a fixed width representation of a non-negative int into the string buffer */ public static void formatInt(StringBuilder sb, int value, int width) { formatInt(sb, value, width, false) ; }
/** Place a fixed width representation into the string buffer : always signed. */ public static void formatSignedInt(StringBuilder sb, int value, int width) { formatInt(sb, value, width, true) ; }
/** Place a fixed width representation of a non-negative int into the string buffer */ public static void formatInt(StringBuilder sb, int value, int width) { formatInt(sb, value, width, false) ; }
/** Place a fixed width representation into the string buffer : always signed. */ public static void formatSignedInt(StringBuilder sb, int value, int width) { formatInt(sb, value, width, true) ; }
/** Place a fixed width representation into the string buffer : always signed. */ public static void formatSignedInt(StringBuilder sb, int value, int width) { formatInt(sb, value, width, true) ; }
/** Place a fixed width representation of a non-negative int into the string buffer */ public static void formatInt(StringBuilder sb, int value, int width) { formatInt(sb, value, width, false) ; }
/** Fast, but basic, integer to StringBuilder : always signed */ public static void formatSignedInt(StringBuilder sb, int value) { int len = length(value) ; if ( value >= 0 ) len++ ; formatInt(sb, value, len, true) ; }
/** Fast, but basic, integer to StringBuilder */ public static void formatInt(StringBuilder sb, int value) { // SeeAlso Integer.toString. int len = length(value) ; formatInt(sb, value, len, false) ; }
/** Fast, but basic, integer to StringBuilder */ public static void formatInt(StringBuilder sb, int value) { // SeeAlso Integer.toString. int len = length(value) ; formatInt(sb, value, len, false) ; }
/** Fast, but basic, integer to StringBuilder */ public static void formatInt(StringBuilder sb, int value) { // SeeAlso Integer.toString. int len = length(value) ; formatInt(sb, value, len, false) ; }
/** Fast, but basic, integer to StringBuilder : always signed */ public static void formatSignedInt(StringBuilder sb, int value) { int len = length(value) ; if ( value >= 0 ) len++ ; formatInt(sb, value, len, true) ; }
/** Fast, but basic, integer to StringBuilder : always signed */ public static void formatSignedInt(StringBuilder sb, int value) { int len = length(value) ; if ( value >= 0 ) len++ ; formatInt(sb, value, len, true) ; }
NumberUtils.formatInt(sb, years, 4); sb.append('-'); NumberUtils.formatInt(sb, months, 2); sb.append('-'); NumberUtils.formatInt(sb, days, 2); if ( isDateTime ) { sb.append('T'); NumberUtils.formatInt(sb, hours, 2); sb.append(':'); NumberUtils.formatInt(sb, minutes, 2); sb.append(':'); NumberUtils.formatInt(sb, sec, 2); sb.append("."); if ( fractionSec % 100 == 0 ) NumberUtils.formatInt(sb, fractionSec / 100, 1); else if ( fractionSec % 10 == 0 ) NumberUtils.formatInt(sb, fractionSec / 10, 2); else NumberUtils.formatInt(sb, fractionSec, 3);
NumberUtils.formatInt(sb, years, 4) ; sb.append('-') ; NumberUtils.formatInt(sb, months, 2) ; sb.append('-') ; NumberUtils.formatInt(sb, days, 2) ; if ( isDateTime ) NumberUtils.formatInt(sb, hours, 2) ; sb.append(':') ; NumberUtils.formatInt(sb, minutes, 2) ; sb.append(':') ; NumberUtils.formatInt(sb, sec, 2) ; NumberUtils.formatInt(sb, fractionSec/100, 1) ; else if ( fractionSec%10 == 0 ) NumberUtils.formatInt(sb, fractionSec/10, 2) ; else NumberUtils.formatInt(sb, fractionSec, 3) ;
private static void testInt(int value, String expected) { StringBuilder sb = new StringBuilder() ; NumberUtils.formatInt(sb, value) ; String result = sb.toString(); assertEquals(expected, result) ; }
private static void testInt(int value, int width, String expected) { StringBuilder sb = new StringBuilder() ; NumberUtils.formatInt(sb, value, width) ; String result = sb.toString(); assertEquals(expected, result) ; }