List of usage examples for java.text NumberFormat getInstance
public static final NumberFormat getInstance()
From source file:net.droidsolutions.droidcharts.core.label.StandardCategoryItemLabelGenerator.java
/** * Creates a new generator with a default number formatter. */ public StandardCategoryItemLabelGenerator() { super(DEFAULT_LABEL_FORMAT_STRING, NumberFormat.getInstance()); }
From source file:com.anrisoftware.fractions.format.FractionFormat.java
@Inject FractionFormat(@Assisted FractionFactory factory) { this.factory = factory; this.numberFormat = NumberFormat.getInstance(); }
From source file:org.dataone.proto.trove.mn.rest.v1.ExceptionController.java
@RequestMapping(value = "/{errorId}", method = RequestMethod.GET) public void get(HttpServletRequest request, HttpServletResponse response, @PathVariable String errorId) throws NotFound, ServiceFailure, NotImplemented, InvalidRequest, InvalidCredentials, NotAuthorized, AuthenticationTimeout, InsufficientResources { int status = 500; log.info("received error of " + errorId); NumberFormat nf = NumberFormat.getInstance(); nf.setParseIntegerOnly(true);/* w w w . j a v a 2 s.c o m*/ try { Number nstatus = nf.parse(errorId); status = nstatus.intValue(); } catch (ParseException ex) { throw new ServiceFailure("500", "Could not determine the server error thrown"); } response.setStatus(status); switch (status) { case 400: { throw new InvalidRequest("400", "Bad Request: The request could not be understood by the server due to malformed syntax."); } case 401: { throw new InvalidCredentials("401", "Unauthorized: The request requires user authentication."); } case 403: { throw new NotAuthorized("403", "Forbidden: The server understood the request, but is refusing to fulfill it. Authorization will not help and the request SHOULD NOT be repeated."); } case 404: { throw new NotFound("404", "Not Found: The server has not found anything matching the Request-URI."); } case 405: { throw new InvalidRequest("405", "Method Not Allowed: The method specified in the Request-Line is not allowed for the resource identified by the Request-URI."); } case 406: { throw new InvalidRequest("406", "Not Acceptable: The resource identified by the request is only capable of generating response entities which have content characteristics not acceptable according to the accept headers sent in the request."); } case 407: { throw new NotAuthorized("407", "Proxy Authentication Required: The client must first authenticate itself with the proxy."); } case 408: { throw new AuthenticationTimeout("408", "Request Timeout: The client did not produce a request within the time that the server was prepared to wait."); } case 409: { throw new InvalidRequest("409", "Conflict: The request could not be completed due to a conflict with the current state of the resource."); } case 410: { throw new NotFound("410", "Gone: The requested resource is no longer available at the server and no forwarding address is known."); } case 411: { throw new InvalidRequest("411", "Length Required: The server refuses to accept the request without a defined Content-Length."); } case 412: { throw new InvalidRequest("412", "Precondition Failed: The precondition given in one or more of the request-header fields evaluated to false when it was tested on the server."); } case 413: { throw new InsufficientResources("413", "Request Entity Too Large: The server is refusing to process a request because the request entity is larger than the server is willing or able to process."); } case 414: { throw new InvalidRequest("414", "Request-URI Too Long: The server is refusing to service the request because the Request-URI is longer than the server is willing to interpret."); } case 415: { throw new InvalidRequest("415", "Unsupported Media Type: The server is refusing to service the request because the entity of the request is in a format not supported by the requested resource for the requested method."); } case 416: { throw new InvalidRequest("416", "Requested Range Not Satisfiable: A server SHOULD return a response with this status code if a request included a Range request-header field."); } case 417: { throw new InvalidRequest("417", "Expectation Failed: The expectation given in an Expect request-header field could not be met by this server."); } case 500: { throw new ServiceFailure("500", "Internal Server Error: The server encountered an unexpected condition which prevented it from fulfilling the request."); } case 501: { throw new NotImplemented("501", "Not Implemented: The server does not support the functionality required to fulfill the request."); } case 502: { throw new ServiceFailure("502", "Bad Gateway: The server, while acting as a gateway or proxy, received an invalid response from the upstream server it accessed in attempting to fulfill the request."); } case 503: { throw new ServiceFailure("503", "Service Unavailable: The server is currently unable to handle the request due to a temporary overloading or maintenance of the server."); } case 504: { throw new ServiceFailure("504", "Gateway Timeout: The server, while acting as a gateway or proxy, did not receive a timely response from the upstream server specified by the URI (e.g. HTTP, FTP, LDAP) or some other auxiliary server (e.g. DNS) it needed to access in attempting to complete the request."); } case 505: { throw new ServiceFailure("505", "HTTP Version Not Supported: The server does not support, or refuses to support, the HTTP protocol version that was used in the request message."); } default: { throw new ServiceFailure("500", "Could not determine the server error thrown"); } } // this.writeToResponse(errorXml.getInputStream(), response.getOutputStream()); }
From source file:com.panet.imeta.trans.steps.getfilenames.GetFileNamesData.java
/** * // w w w . j a v a 2 s .c o m */ public GetFileNamesData() { super(); lineBuffer = new ArrayList<String>(); nf = NumberFormat.getInstance(); df = (DecimalFormat) nf; dfs = new DecimalFormatSymbols(); daf = new SimpleDateFormat(); dafs = new DateFormatSymbols(); nr_repeats = 0; previous_row = null; filenr = 0; filessize = 0; nrLinesOnPage = 0; fr = null; zi = null; file = null; totalpreviousfields = 0; indexOfFilenameField = -1; indexOfWildcardField = -1; readrow = null; nrStepFields = 0; }
From source file:net.sourceforge.eclipsetrader.charts.ChartsPlugin.java
public static NumberFormat getNumberFormat() { if (numberFormat == null) { numberFormat = NumberFormat.getInstance(); numberFormat.setGroupingUsed(true); numberFormat.setMinimumIntegerDigits(1); numberFormat.setMinimumFractionDigits(0); numberFormat.setMaximumFractionDigits(0); }//from w w w . j a v a 2 s . com return numberFormat; }
From source file:com.alibaba.json.test.JSONParser2Test.java
public void f_ali_json() throws Exception { // String input = "[{\"a\":3}]"; long startNano = System.nanoTime(); for (int i = 0; i < COUNT; ++i) { DefaultJSONParser parser = new DefaultJSONParser(text); parser.parse();//from w w w . j av a2 s .co m } long nano = System.nanoTime() - startNano; System.out.println("fast-json \t: " + NumberFormat.getInstance().format(nano)); }
From source file:com.discursive.jccook.collections.bag.BagExample.java
private void printAlbums(Bag albumBag) { Set albums = albumBag.uniqueSet(); Iterator albumIterator = albums.iterator(); while (albumIterator.hasNext()) { Album album = (Album) albumIterator.next(); NumberFormat format = NumberFormat.getInstance(); format.setMinimumIntegerDigits(3); format.setMaximumFractionDigits(0); System.out.println("\t" + format.format(albumBag.getCount(album)) + " - " + album.getBand()); }// w w w . j ava 2 s . c o m }
From source file:com.panet.imeta.trans.steps.ldifinput.LDIFInputData.java
/** * // w w w . j a v a 2s .co m */ public LDIFInputData() { super(); nrInputFields = -1; thisline = null; nextline = null; nf = NumberFormat.getInstance(); df = (DecimalFormat) nf; dfs = new DecimalFormatSymbols(); daf = new SimpleDateFormat(); dafs = new DateFormatSymbols(); nr_repeats = 0; filenr = 0; fr = null; zi = null; is = null; InputLDIF = null; recordLDIF = null; multiValueSeparator = ","; totalpreviousfields = 0; readrow = null; indexOfFilenameField = -1; }
From source file:diet.gridr.g5k.util.ExtendedStackedBarRenderer.java
/** * Creates a new renderer. */ public ExtendedStackedBarRenderer() { super(); this.totalFormatter = NumberFormat.getInstance(); }
From source file:com.streamsets.datacollector.util.SystemProcessImpl.java
/** * @return a unique number which shorts in descending order *//* www . j ava 2 s . co m*/ private static String nextId() { NumberFormat numberFormat = NumberFormat.getInstance(); numberFormat.setMinimumIntegerDigits(10); numberFormat.setGroupingUsed(false); SimpleDateFormat dateFormat = new SimpleDateFormat("YYYY-MM-dd_HH.mm.ss"); return Utils.format("{}-{}", dateFormat.format(new Date()), numberFormat.format(fileCounter.incrementAndGet())); }