Java Hour Format format(double number, int decimalPlace)

Here you can find the source of format(double number, int decimalPlace)

Description

format

License

Open Source License

Declaration

public static String format(double number, int decimalPlace) 

Method Source Code

//package com.java2s;
/* /*from ww w  .  j  a v  a2 s  .  com*/
 * TURNUS, the co-exploration framework
 * 
 * Copyright (C) 2014 EPFL SCI STI MM
 *
 * This file is part of TURNUS.
 *
 * TURNUS 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, either version 3 of the License, or
 * (at your option) any later version.
 *
 * TURNUS 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 TURNUS.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * Additional permission under GNU GPL version 3 section 7
 * 
 * If you modify this Program, or any covered work, by linking or combining it
 * with Eclipse (or a modified version of Eclipse or an Eclipse plugin or 
 * an Eclipse library), containing parts covered by the terms of the 
 * Eclipse Public License (EPL), the licensors of this Program grant you 
 * additional permission to convey the resulting work.  Corresponding Source 
 * for a non-source form of such a combination shall include the source code 
 * for the parts of Eclipse libraries used as well as that of the  covered work.
 * 
 */

import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {
    public static String format(Date date) {
        return format(date, "yyyy.MM.dd, HH:mm:ss");
    }

    public static String format(Date date, String dateFormat) {
        SimpleDateFormat dateFormatter = new SimpleDateFormat(dateFormat);
        return dateFormatter.format(date);
    }

    public static String format(double number, int decimalPlace) {
        DecimalFormat df = new DecimalFormat();
        df.setMaximumFractionDigits(decimalPlace);
        return df.format(number);
    }
}

Related

  1. format(Date date, String ptrn)
  2. format(Date dateTime)
  3. format(Date dt)
  4. format(Date self, String format, TimeZone tz)
  5. format(Date time, String fmt)
  6. format(final Date date)
  7. format(final Date date)
  8. format(final Date date)
  9. format(int level, String message, String source, boolean verbose)