/** * Format a percentage for presentation to the user. * @param fraction the percentage as a fraction, e.g. 0.1 = 10% * @param decimalPlaces the number of decimal places * @return a string representation of the percentage */ public static String formatPercent(double fraction, int decimalPlaces) { return format("%." + decimalPlaces + "f%%", fraction*100); }
/** @deprecated use StringUtils.format("%.2f", d). */ @Deprecated public static String limitDecimalTo2(double d) { return format("%.2f", d); }
/** * Given an array of bytes it will convert the bytes to a hex string * representation of the bytes * @param bytes * @param start start index, inclusively * @param end end index, exclusively * @return hex string representation of the byte array */ public static String byteToHexString(byte[] bytes, int start, int end) { if (bytes == null) { throw new IllegalArgumentException("bytes == null"); } StringBuilder s = new StringBuilder(); for(int i = start; i < end; i++) { s.append(format("%02x", bytes[i])); } return s.toString(); }
String cmd = StringUtils.format( "--connect \"%s\" --driver %s --username %s --password %s --query \"%s AND \\$CONDITIONS\" " + "--target-dir %s/%s --split-by %s --boundary-query \"%s\" --null-string '' "
/** * Format a percentage for presentation to the user. * @param fraction the percentage as a fraction, e.g. 0.1 = 10% * @param decimalPlaces the number of decimal places * @return a string representation of the percentage */ public static String formatPercent(double fraction, int decimalPlaces) { return format("%." + decimalPlaces + "f%%", fraction*100); }
/** * Format a percentage for presentation to the user. * @param fraction the percentage as a fraction, e.g. 0.1 = 10% * @param decimalPlaces the number of decimal places * @return a string representation of the percentage */ public static String formatPercent(double fraction, int decimalPlaces) { return format("%." + decimalPlaces + "f%%", fraction*100); }
static String left(float f) { return StringUtils.format("left:%.1f%%", f * 100); } }
static String left(float f) { return StringUtils.format("left:%.1f%%", f * 100); } }
/** * Format a percentage for presentation to the user. * @param fraction the percentage as a fraction, e.g. 0.1 = 10% * @param decimalPlaces the number of decimal places * @return a string representation of the percentage */ public static String formatPercent(double fraction, int decimalPlaces) { return format("%." + decimalPlaces + "f%%", fraction * 100); }
/** Convert percentage to a string. */ public static String percent2String(double percentage) { return StringUtils.format("%.2f%%", percentage); }
/** * Format a percentage for presentation to the user. * @param fraction the percentage as a fraction, e.g. 0.1 = 10% * @param decimalPlaces the number of decimal places * @return a string representation of the percentage */ public static String formatPercent(double fraction, int decimalPlaces) { return format("%." + decimalPlaces + "f%%", fraction*100); }
static String width(float f) { return StringUtils.format("width:%.1f%%", f * 100); }
static String left(float f) { return StringUtils.format("left:%.1f%%", f * 100); } }
/** @deprecated use StringUtils.format("%.2f", d). */ @Deprecated public static String limitDecimalTo2(double d) { return format("%.2f", d); }
/** @deprecated use StringUtils.format("%.2f", d). */ @Deprecated public static String limitDecimalTo2(double d) { return format("%.2f", d); }
/** @deprecated use StringUtils.format("%.2f", d). */ @Deprecated public static String limitDecimalTo2(double d) { return format("%.2f", d); }
/** @deprecated use StringUtils.format("%.2f", d). */ @Deprecated public static String limitDecimalTo2(double d) { return format("%.2f", d); }
public static final String createNewLogFile(FileSystem fs, String basePath, String partitionPath, String commitTime, String fileID, Optional<Integer> version) throws IOException { String folderPath = basePath + "/" + partitionPath + "/"; boolean makeDir = fs.mkdirs(new Path(folderPath)); if (!makeDir) { throw new IOException("cannot create directory for path " + folderPath); } boolean createFile = fs.createNewFile(new Path( folderPath + FSUtils.makeLogFileName(fileID, ".log", commitTime, version.orElse(DEFAULT_TASK_PARTITIONID)))); if (!createFile) { throw new IOException( StringUtils.format("cannot create data file for commit %s and fileId %s", commitTime, fileID)); } return fileID; }