Java Hour Format formatSingleFractionHours(Double updatedHours)

Here you can find the source of formatSingleFractionHours(Double updatedHours)

Description

public for testing Formats input as single digit fraction string

License

Open Source License

Declaration

public static String formatSingleFractionHours(Double updatedHours) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2007, 2009 CodeGear and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/

import java.text.NumberFormat;

import java.util.Locale;

public class Main {
    /**/*from   w  w  w  .  j a v  a2s .  c o  m*/
     * public for testing Formats input as single digit fraction string
     */
    public static String formatSingleFractionHours(Double updatedHours) {
        NumberFormat format = getHoursNumberFormat();
        return format.format(updatedHours);
    }

    public static NumberFormat getHoursNumberFormat() {
        return getHoursNumberFormat(Locale.getDefault());
    }

    public static NumberFormat getHoursNumberFormat(Locale locale) {
        NumberFormat format = NumberFormat.getInstance(locale);
        format.setMaximumIntegerDigits(5);
        format.setMinimumFractionDigits(1);
        format.setMaximumFractionDigits(1);
        format.setGroupingUsed(false);
        format.setParseIntegerOnly(false);
        return format;
    }
}

Related

  1. formatRuntime(long runtime)
  2. formatSDate(java.util.Date date)
  3. formatShortDate(java.util.Date date)
  4. formatShortTime()
  5. formatSimpleTimeAndDateString(Date date)
  6. formatSQL(Date date)
  7. formatSqlDateTime(Date value)
  8. formatSSLValid(Date validFrom, Date validTo)
  9. formatStringTime(String dateTime)