List of usage examples for java.util Formatter Formatter
public Formatter()
From source file:com.rackspace.api.clients.veracode.responses.UploadResponse.java
public String getBuildId(int buildVersion) { Formatter formatter = new Formatter(); String buildId = null;//from w w w . j ava 2s.com try { buildId = (String) xpath.evaluate(formatter.format(XPATH_EXPRESSION, buildVersion).toString(), doc, XPathConstants.STRING); } catch (XPathExpressionException e) { throw new RuntimeException(e); } return buildId; }
From source file:com.opentok.test.Helpers.java
private static String toHexString(byte[] bytes) { Formatter formatter = new Formatter(); for (byte b : bytes) { formatter.format("%02x", b); }/*from w ww .ja va 2 s. c o m*/ return formatter.toString(); }
From source file:com.base.service.WeixinService.java
private static String byteToHex(final byte[] hash) { Formatter formatter = new Formatter(); for (byte b : hash) { formatter.format("%02x", b); }//from w ww. j av a2s. c om String result = formatter.toString(); formatter.close(); return result; }
From source file:ar.com.zauber.garfio.services.impl.HourMinuteTimeConverter.java
/** @see TimeConverter#toHours(String)*/ public final String toHours(final String time) { Validate.isTrue(supportsTime(time)); Matcher m = timePattern.matcher(time); m.matches();/*from w ww . ja va 2 s . com*/ StringBuilder builder = new StringBuilder(); if (m.group(1) != null) { builder.append(m.group(1)); } if (m.group(3) != null) { /* Only hour */ builder.append(m.group(3)); } else if (m.group(5) != null || m.group(6) != null) { /* [xxh]yym */ if (m.group(5) != null) { builder.append(m.group(5)); } else { builder.append("0"); } if (m.group(6) != null) { Formatter f = new Formatter(); f.format(Locale.US, ".%02.0f", 100 * minutesToHours(Integer.valueOf(m.group(6)))); builder.append(f.toString()); } } else { /* Only minutes >= 60 */ Formatter f = new Formatter(); f.format(Locale.US, "%.2f", minutesToHours(Integer.valueOf(m.group(7)))); builder.append(f.toString()); } return builder.toString(); }
From source file:cc.recommenders.utils.Fingerprints.java
private static String toHexString(final byte[] hash) { ensureIsNotNull(hash);//from w ww . j av a 2 s . co m // this is said to be very slow... - we may look at this if hashing // actually takes too long. final Formatter formatter = new Formatter(); for (final byte b : hash) { formatter.format("%02x", b); } String out = formatter.toString(); formatter.close(); return out; }
From source file:com.flexive.tests.embedded.benchmark.logger.XmlLogger.java
/** {@inheritDoc} */ @Override//from w ww. jav a2 s . c o m protected synchronized void logResult(String name, double value, String measurement, String unit) { Assert.assertTrue(active, "ResultLogger invoked after getOutput has been called"); wax.start("result").child("name", name).child("value", new Formatter().format("%.5f", value).toString()) .child("unit", unit).child("measurement", measurement).end(); }
From source file:org.jasig.cas.CasEnvironmentContextListener.java
/** * Collect environment info with/*w w w . j a v a 2 s. co m*/ * details on the java and os deployment * versions. * * @return environment info */ private String collectEnvironmentInfo() { final Properties properties = System.getProperties(); final Formatter formatter = new Formatter(); formatter.format("\n******************** Welcome to CAS ********************\n"); formatter.format("CAS Version: %s\n", CasVersion.getVersion()); formatter.format("Java Home: %s\n", properties.get("java.home")); formatter.format("Java Vendor: %s\n", properties.get("java.vendor")); formatter.format("Java Version: %s\n", properties.get("java.version")); formatter.format("OS Architecture: %s\n", properties.get("os.arch")); formatter.format("OS Name: %s\n", properties.get("os.name")); formatter.format("OS Version: %s\n", properties.get("os.version")); formatter.format("*******************************************************\n"); return formatter.toString(); }
From source file:com.userweave.domain.service.impl.GeneralStatisticsImpl.java
@Override public String getAverageToMinute() { long seconds = getAverage() % 60; long minutes = getAverage() / 60L; return new Formatter().format("%d:%02d", minutes, seconds).toString(); }
From source file:fr.gael.dhus.sync.smart.download.ProductDownloadTask.java
/** * raise an IOException with the given StatusLine and cause Header (cause may be null). */// w w w .j a va 2 s . c o m private void raiseFailure(StatusLine stl, Header cause) throws IOException { Formatter ff = new Formatter(); ff.format("Cannot download %s, Reason='%s' (HTTP%d)", this.url, stl.getReasonPhrase(), stl.getStatusCode()); if (cause != null) { String cause_msg = cause.getValue(); if (cause_msg != null && !cause_msg.isEmpty()) { ff.format(" Cause='%s'", cause_msg); } } IOException exception = new IOException(ff.out().toString()); ff.close(); throw exception; }
From source file:com.quarterfull.newsAndroid.VersionInfoDialogFragment.java
private String getVersionString() { String version = "?"; try {//from w w w .ja v a 2 s . co m PackageInfo pInfo = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0); version = pInfo.versionName; } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } Formatter formatter = new Formatter(); String versionString = getString(R.string.current_version); return formatter.format(versionString, version).toString(); }