Package java.text

Examples of java.text.DecimalFormat$DigitArrays


   */
   public final String nice(long iterations) {
      stop();
      long elapsed = elapsed();
      double perMilli = (double)iterations / (double)elapsed;
      DecimalFormat df = ((DecimalFormat)NumberFormat.getInstance());
      if (perMilli > 10000.) {
         df.applyPattern("########");
         return Timestamp.millisToNice(elapsed) + " for " + iterations + " iterations -> " + df.format(perMilli/1000) + " iterations/microsecond";
      }
      else if (perMilli > 100.)
         df.applyPattern("########");
      else if (perMilli > 10.)
         df.applyPattern("######.#");
      else if (perMilli > 0.1) {
         df.applyPattern("######.#");
         return Timestamp.millisToNice(elapsed) + " for " + iterations + " iterations -> " + df.format(perMilli*1000) + " iterations/second";
      }
      else {
         df.applyPattern("##########");
         return Timestamp.millisToNice(elapsed) + " for " + iterations + " iterations -> " + df.format(perMilli*1000) + " iterations/second";
      }
      return Timestamp.millisToNice(elapsed) + " for " + iterations + " iterations -> " + df.format(perMilli) + " iterations/millisecond";
   }
View Full Code Here



  public void testDefaultIntFacetIterator()
  {
    String format = "00";
    DecimalFormat df = new DecimalFormat(format);
    List<IntFacetIterator> list = new ArrayList<IntFacetIterator>();
    for(int seg = 0; seg < 5; seg++)
    {
      TermIntList tsl1 = new TermIntList(format);
      int limit = 25;
      int [] count = new int[limit];
      String[] terms = new String[limit];
      for(int i = limit - 1; i>=0; i--)
      {
        terms[i] = df.format(i);
      }
      Arrays.sort(terms);
      for(int i = 0; i< limit; i++)
      {
        tsl1.add(terms[i]);
View Full Code Here

    }
    //Arrays.fill(cache.freqs,1);
    cache.maxIDs = new int[numVals];
    cache.minIDs = new int[numVals];
    cache.valArray = new TermIntList(numVals,"0000000000");
    DecimalFormat formatter = new DecimalFormat("0000000000");
   
    for (int i=0;i<numVals;++i){
      cache.valArray.add(formatter.format(i+1));
    }
    cache.valArray.seal();
    cache.orderArray = new BigIntArray(numDocsPerSeg);
    return cache;
  }
View Full Code Here

    //Comparable c = "00000000001";
    //Comparable c2 ="00000000002";
  //  Comparable c = Integer.valueOf(1);
  //  Comparable c2 = Integer.valueOf(2);

    DecimalFormat formatter = new DecimalFormat("0000000000");
   
    int count = 500000;
    TermValueList list = new TermIntList(count,"0000000000");
    for (int i=0;i<count;++i){
      list.add(formatter.format(i));
    }
    /*IntList list = new IntArrayList(count);
    for (int i=0;i<count;++i){
      list.add(i);
    }*/
 
View Full Code Here

      hours = length / 3600;
      length = length - (hours * 3600);
      minutes = length / 60;
      length = length - (minutes * 60);
      seconds = length;
      DecimalFormat doubleDigit = new DecimalFormat("00");
      String res = "";
      if (hours > 0) {
        res = doubleDigit.format(hours) + ":";
      }
      res += doubleDigit.format(minutes) + ":";
      res += doubleDigit.format(seconds);

      info.add(res);
      info.add(audioFile.getAudioHeader().getBitRate().trim() + "kbps");

      setCleanedContent(concatenateStringParts(info, Integer.MAX_VALUE));
View Full Code Here

 
  public boolean store(JDCConnection oConn, String sLanguage) throws SQLException,IllegalStateException,NullPointerException {   
  Date dtNow = new Date();
    Locale oLoc = new Locale(sLanguage);
    SimpleDateFormat oXMLDate = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
  DecimalFormat oNumFmt = (DecimalFormat) NumberFormat.getNumberInstance(oLoc);
  oNumFmt.setMaximumFractionDigits(2);

    if (!containsKey(DB.gu_project)) throw new NullPointerException("DutiesWorkReport duties report, project is required");
    if (!containsKey(DB.gu_writer)) throw new NullPointerException("DutiesWorkReport duties report, writer user is required");
    
    if (containsKey(DB.gu_workreport)) {
      if (DBCommand.queryExists(oConn, DB.k_duties_workreports, DB.gu_workreport+"='"+getString(DB.gu_workreport)+"'"))
        throw new IllegalStateException("DutiesWorkReport, it is not allowed to update an already existing report");   
    } else {
      put(DB.gu_workreport, Gadgets.generateUUID());
    }
   
  if (!containsKey(DB.tl_workreport)) {
    String sNmProject = DBCommand.queryStr(oConn, "SELECT "+DB.nm_project+" FROM "+DB.k_projects+" WHERE "+DB.gu_project+"='"+getStringNull(DB.gu_project,"")+"'");
    put(DB.tl_workreport, sNmProject+" "+dtNow.toString());
  }

  ACLUser oWriter = new ACLUser(oConn, getString(DB.gu_writer));
  Project oProj = new Project(oConn, getString(DB.gu_project));

   HashMap oPrioritiesMap = DBLanguages.getLookUpMap(oConn, DB.k_duties_lookup, oProj.getString(DB.gu_owner), DB.od_priority, sLanguage);
   HashMap oDutyTypesMap = DBLanguages.getLookUpMap(oConn, DB.k_duties_lookup, oProj.getString(DB.gu_owner), DB.tp_duty, sLanguage);
   HashMap oStatusMap = DBLanguages.getLookUpMap(oConn, DB.k_duties_lookup, oProj.getString(DB.gu_owner), DB.tx_status, sLanguage);
   HashMap oResourcesMap = DBLanguages.getLookUpMap(oConn, DB.k_duties_lookup, oProj.getString(DB.gu_owner), DB.nm_resource, sLanguage);

    int nDuties = oDuties.size();
    StringBuffer oStrBuf = new StringBuffer(1000+500*nDuties);

    oStrBuf.append("<DutiesWorkReport>\n");

    oStrBuf.append("<tl_workreport><![CDATA["+getString(DB.tl_workreport)+"]]></tl_workreport>\n");
    oStrBuf.append("<dt_created>"+oXMLDate.format(dtNow)+"</dt_created>\n");
    oStrBuf.append("<de_workreport><![CDATA["+getStringNull(DB.de_workreport,"")+"]]></de_workreport>\n");

    oStrBuf.append("<Writer>\n");
    oStrBuf.append("  <tx_nickname>"+oWriter.getStringNull(DB.tx_nickname,"")+"</tx_nickname>\n");
    oStrBuf.append("  <tx_full_name><![CDATA["+(oWriter.getStringNull(DB.nm_user,"")+" "+oWriter.getStringNull(DB.tx_surname1,"")+" "+oWriter.getStringNull(DB.tx_surname2,"")).trim()+"]]></tx_full_name>\n");
    oStrBuf.append("  <nm_company><![CDATA["+oWriter.getStringNull(DB.nm_company,"")+"]]></nm_company>\n");
    oStrBuf.append("  <tx_main_email><![CDATA["+oWriter.getStringNull(DB.tx_main_email,"")+"]]></tx_main_email>\n");
    oStrBuf.append("</Writer>\n");

    oStrBuf.append(oProj.toXML());
    oStrBuf.append('\n');

  PreparedStatement oStmt = oConn.prepareStatement("SELECT "+DB.nm_resource+","+DB.pct_time+" FROM "+DB.k_x_duty_resource+" WHERE "+DB.gu_duty+"=?",
                           ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
    oStrBuf.append("<Duties count=\""+String.valueOf(nDuties)+"\">\n");
    for (int d=0; d<nDuties; d++) {
      Duty oDut = oDuties.get(d);
      oStrBuf.append("<Duty>\n");
      oStrBuf.append("  <gu_duty>"+oDut.getString(DB.gu_duty)+"</gu_duty>\n");
      oStrBuf.append("  <nm_duty>"+oDut.getString(DB.nm_duty)+"</nm_duty>\n");
      if (oDut.isNull(DB.dt_modified)) oStrBuf.append("  <dt_modified/>\n"); else oStrBuf.append("  <dt_modified>"+oXMLDate.format(oDut.getDate(DB.dt_modified))+"</dt_modified>\n");
      if (oDut.isNull(DB.dt_start)) oStrBuf.append("  <dt_start/>\n"); else oStrBuf.append("  <dt_start>"+oDut.getDateShort(DB.dt_start)+"</dt_start>\n");
      if (oDut.isNull(DB.dt_end)) oStrBuf.append("  <dt_end/>\n"); else oStrBuf.append("  <dt_end>"+oDut.getDateShort(DB.dt_end)+"</dt_end>\n");
    if (oDut.isNull(DB.ti_duration)) oStrBuf.append("  <ti_duration/>\n"); else oStrBuf.append("  <ti_duration>"+oDut.getDecimalFormated(DB.ti_duration,oLoc,2)+"</ti_duration>\n");
    if (oDut.isNull(DB.pr_cost)) oStrBuf.append("  <pr_cost/>\n"); else oStrBuf.append("  <pr_cost>"+oNumFmt.format(new BigDecimal(oDut.getFloat(DB.pr_cost)))+"</pr_cost>\n");
    if (oDut.isNull(DB.pct_complete)) oStrBuf.append("  <pct_complete/>\n"); else oStrBuf.append("  <pct_complete>"+String.valueOf(oDut.getFloat(DB.pct_complete)+"</pct_complete>\n"));
    if (oDut.isNull(DB.od_priority)) {
      oStrBuf.append("  <od_priority/>\n");
    } else {
    Object oPriority = oPrioritiesMap.get(oDut.get(DB.od_priority));
View Full Code Here

   *            the time to create a string of.
   * @return A string storing the id3v2.4 timestamp.
   */
  private static String createString(Calendar calendar) {
    StringBuffer result = new StringBuffer();
    result.append(new DecimalFormat("0000").format(calendar
        .get(Calendar.YEAR)));
    return result.toString();
  }
View Full Code Here

      String firstTrack = audioFile.getTag().getFirstTrack();
      try {
        if (firstTrack != null) {
          int number = Integer.parseInt(firstTrack);
          if (decFormatter == null) {
            decFormatter = new DecimalFormat("00");
          }
          audioFile.getTag().setTrack(decFormatter.format(number));
        }
      } catch (NumberFormatException nfe) {
        // Nothing to do
View Full Code Here

      assertEquals("2011", Util.toFourDigitYear("11", 2001));
     
      int thisYear = Calendar.getInstance().get(Calendar.YEAR);
      int d2 = thisYear % 100;

      NumberFormat f = new DecimalFormat("00");
     
      for (int i = 0; i <= 30; i++){
        assertTrue("" + i, thisYear <= Integer.parseInt(Util.toFourDigitYear(f.format((d2 + i) % 100))));
      }
      for (int i = 0; i < 70; i++){
        assertTrue("" + i, thisYear >= Integer.parseInt(Util.toFourDigitYear(f.format((d2 - i + 100) % 100))));
      }
    }
View Full Code Here

  // The name cannot be null - use empty string instead
  if (name == null) name = EMPTYSTRING;

  // Construct a DecimalFormat object containing the symbols we got
  final DecimalFormat df = new DecimalFormat();
  if (symbols != null) {
      df.setDecimalFormatSymbols(symbols);
  }
  _formatSymbols.put(name, df);
    }
View Full Code Here

TOP

Related Classes of java.text.DecimalFormat$DigitArrays

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.