Package java.util

Examples of java.util.Formatter$FormatSpecifier


    @Override
    public String toString()
    {
      StringBuilder resBuilder = new StringBuilder(100);
      Formatter fmt = new Formatter(resBuilder);
      try
      {
        fmt.format("{\"batchingLevel\":\"%s\",\"streamBatchSize\":%d,\"bootstrapBatchSize\":%d}",
                   _batchingLevel.toString(), _streamBatchSize, _bootstrapBatchSize);
 
        fmt.flush();
        return fmt.toString();
      }
      finally
      {
        fmt.close();
      }
    }
View Full Code Here


            int hour = 60 * minute;
            long hours = millis / hour;
            long minutes = (millis % hour) / minute;
            long seconds = ((millis % hour) % minute) / second;
            long milliseconds = ((millis % hour) % minute % second);
            Formatter formatter = new Formatter();
            String result = formatter.format("%02d:%02d:%02d.%03d", hours, minutes, seconds, milliseconds).toString();
            formatter.close();
            return result;
        }
View Full Code Here

      return "";
    }
    pathFormat = pathFormat.replace('/', File.separatorChar);
    StringBuilder strBuffer = new StringBuilder();

    Formatter formatter = new Formatter(strBuffer, Locale.US);
    formatter.format(pathFormat, date);
    formatter.close();

    if (!pathFormat.endsWith(File.separator)) {
      strBuffer.append(File.separator);
    }
View Full Code Here

    private static void out(String level, String msg, Throwable t, Object... args) {
        PrintWriter out = INSTANCE.out;
        synchronized(out) {
            StackTraceElement el = getLine();
            Formatter formatter = new Formatter();
            try {
                String location = formatter.format("(%s:%d)", el.getFileName(), el.getLineNumber()).toString();
                out.printf("vlcj: %-46s | %-5s | %s%n", location, level, format(msg, args));
                out.flush();
                if(t != null) {
                    PrintWriter err = INSTANCE.err;
                    err.printf("vlcj: %-46s | %-5s | %s%n", location, level, t.getMessage());
                    err.flush();
                    t.printStackTrace();
                }
            }
            finally {
                formatter.close();
            }
        }
    }
View Full Code Here

    }

    CharSequence inspect(Object b)
    {
        boolean found = false;
        Formatter f = new Formatter();
        Method methods[] = b.getClass().getMethods();
        for (Method m : methods)
        {
            try
            {
                String name = m.getName();
                if (m.getName().startsWith("get") && !m.getName().equals("getClass")
                    && m.getParameterTypes().length == 0
                    && Modifier.isPublic(m.getModifiers()))
                {
                    found = true;
                    name = name.substring(3);
                    m.setAccessible(true);
                    Object value = m.invoke(b, (Object[]) null);
                    f.format(COLUMN, name, format(value, Converter.LINE, this));
                }
            }
            catch (IllegalAccessException e)
            {
                // Ignore
            }
            catch (Exception e)
            {
                e.printStackTrace();
            }
        }
        if (found)
        {
            return (StringBuilder) f.out();
        }
        else
        {
            return b.toString();
        }
View Full Code Here

    protected void pumpDataIntoTestCollection() {
        // there should be 100 of each
        String[] scientists = {"Einstein", "Darwin", "Copernicus", "Pasteur", "Curie", "Faraday", "Newton", "Bohr", "Galilei", "Maxwell"};
        for (int i = 1; i <= 1000; i++) {
            int index = i % scientists.length;
            Formatter f = new Formatter();
            String doc = f.format("{\"_id\":\"%d\", \"scientist\":\"%s\", \"fixedField\": \"fixedValue\"}", i, scientists[index]).toString();
            IOHelper.close(f);
            testCollection.insert((DBObject) JSON.parse(doc), WriteConcern.SAFE);
        }
        assertEquals("Data pumping of 1000 entries did not complete entirely", 1000L, testCollection.count());
    }
View Full Code Here

    public void testUpdate() throws Exception {
        // Prepare test
        assertEquals(0, testCollection.count());
        for (int i = 1; i <= 100; i++) {
            String body = null;
            Formatter f = new Formatter();
            if (i % 2 == 0) {
                body = f.format("{\"_id\":\"testSave%d\", \"scientist\":\"Einstein\"}", i).toString();
            } else {
                body = f.format("{\"_id\":\"testSave%d\", \"scientist\":\"Einstein\", \"extraField\": true}", i).toString();
            }
            f.close();
            template.requestBody("direct:insert", body);
        }
        assertEquals(100L, testCollection.count());
       
        // Testing the update logic
View Full Code Here

    public void testRemove() throws Exception {
        // Prepare test
        assertEquals(0, testCollection.count());
        for (int i = 1; i <= 100; i++) {
            String body = null;
            Formatter f = new Formatter();
            if (i % 2 == 0) {
                body = f.format("{\"_id\":\"testSave%d\", \"scientist\":\"Einstein\"}", i).toString();
            } else {
                body = f.format("{\"_id\":\"testSave%d\", \"scientist\":\"Einstein\", \"extraField\": true}", i).toString();
            }
            f.close();
            template.requestBody("direct:insert", body);
        }
        assertEquals(100L, testCollection.count());
       
        // Testing the update logic
View Full Code Here

        assertEquals(0, testCollection.count());
       
        // Add some records to the collection (and do it via camel-mongodb)
        for (int i = 1; i <= 100; i++) {
            String body = null;
            Formatter f = new Formatter();
            body = f.format("{\"_id\":\"testSave%d\", \"scientist\":\"Einstein\"}", i).toString();
            f.close();
            template.requestBody("direct:insert", body);
        }
       
        Object result = template.requestBody("direct:getColStats", "irrelevantBody");
        assertTrue("Result is not of type DBObject", result instanceof DBObject);
View Full Code Here

 
  /**
   * @return
   */
  public EString to_list() {
    Formatter form = new Formatter();
    form = form.format("%.20e", value);
    String value = form.toString();
    return new EString(value);
  }
View Full Code Here

TOP

Related Classes of java.util.Formatter$FormatSpecifier

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.