Java Formatter Usage getCommitCounterStr(final long commitCounter)

Here you can find the source of getCommitCounterStr(final long commitCounter)

Description

Format the commit counter with leading zeros such that it will be lexically ordered in the file system.

License

Open Source License

Parameter

Parameter Description
commitCounter The commit counter.

Return

The basename of the file consisting of the foramtted commit counter with the appropriate leading zeros.

Declaration

public static String getCommitCounterStr(final long commitCounter) 

Method Source Code

//package com.java2s;
/**/*from   w w w . j  av a 2s .co m*/
    
Copyright (C) SYSTAP, LLC 2006-2007.  All rights reserved.
    
Contact:
 SYSTAP, LLC
 4501 Tower Road
 Greensboro, NC 27410
 licenses@bigdata.com
    
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
    
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
    
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

import java.util.Formatter;

public class Main {
    /**
     * Format the commit counter with leading zeros such that it will be
     * lexically ordered in the file system.
     * 
     * @param commitCounter
     *            The commit counter.
     *            
     * @return The basename of the file consisting of the foramtted commit
     *         counter with the appropriate leading zeros.
     */
    public static String getCommitCounterStr(final long commitCounter) {

        final StringBuilder sb = new StringBuilder(21);

        final Formatter f = new Formatter(sb);

        f.format("%021d", commitCounter);
        f.flush();
        f.close();

        final String basename = sb.toString();

        return basename;

    }
}

Related

  1. formatTzname(final String format, final String letter)
  2. formatv(String format, Object[] args)
  3. formatZeroDecimals(Number x)
  4. fperfdata(String label, double val, String uom, int warnp, double warn, int critp, double crit, boolean minp, double minv, boolean maxp, double maxv)
  5. generateMacOnIncrease(final String baseMac, final long l)
  6. getFormatedTime(double timeInSeconds)
  7. getPropertiesString(Properties myProps)
  8. GetRawView(String string)
  9. getRoundedString(double value, int powerOf10)