Java - Write code to Convert a double to a string by format

Requirements

Write code to Convert a double to a string by format

Demo

//package com.book2s;
import java.text.DecimalFormat;

public class Main {
    public static void main(String[] argv) {
        double value = 42.45678;
        String format = "##.##";
        System.out.println(doubleToString(value, format));
    }/*from  w  w w .  java2  s .  c  om*/

    /**
     * Converts a double to a string.
     * 
     * @param value
     * @param format
     *          The format, e.g. #.00
     * @return
     */
    public static String doubleToString(double value, String format) {
        return new DecimalFormat(format).format(value);
    }
}