Share on Google+Share on Google+

Desiree Luciane
1 Answer(s)      6 years and 11 months ago
Posted in : Java Beginners

Assume that the double variable number holds the value 459.6329. What format pattern would you use to display the number as 00459.633?

Thank you.

View Answers

November 15, 2010 at 11:05 AM

Hi Friend,

You can use the following code:

import java.text.*;

public class DecimalFormatExample{
    public static void main(String args[]){
    double amount = 459.6329;
    DecimalFormat formatter = new DecimalFormat("00000.000");
    System.out.println("The Decimal Value is:"+formatter.format(amount));



Related Tutorials/Questions & Answers:
args[]){ double amount = 459.6329; DecimalFormat formatter = new
Help in making a text formatter
Help in making a text formatter  I have a question on how to make a text formatter using Java. I attempted in doing so, but got a really low score on it, and so I'm having to rely on someone kind enough to help me. We use
Date Formatter in JSP
Date Formatter in JSP       This section illustrates you how to use date formatter. To display the date in different formats, we have used DateFormat class. This class provides
Creating a Custom Formatter for a Logger Handler in Java
Creating a Custom Formatter for a Logger Handler in Java... a custom formatter for a logger handler. Java provides two types formatter... a custom formatter through the logger handler. Here you will see custom formatter
Setting the Formatter of a Logger Handler in Java
Setting the Formatter of a Logger Handler in Java  ... the formatter of a logger handler. Java provides a logger handler that uses a formatter... is XMLFormatter. Simple Formatter is used to write a file with simple text while
Pattern,Matcher,Formatter and Scanner classes
Pattern,Matcher,Formatter and Scanner classes This section Describes : 1... using the Formatter and Scanner classes and the PrintWriter.format/printf... or a Formatter respectively for these classes, allowing method call chaining
Simple date formatter example
Simple date formatter example       In this section of simple date formatter example we... formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String formattedDate
Java Package Formatter
Java Package Formatter       When you want to format multiple Java source in Eclipse the only way is to open each and every file, right click in the editor window
Eclipse Perl Integration
assist, perldoc support, source formatter, templating support and a Perl
Astyle Eclipse Plugin
Astyle Eclipse Plugin       Astyle Eclipse is based on Astyle program, it aims to provide a C/C++ formatter for CDT plugin in eclipse. so all the supported
Parameter month I Report - Java Beginners
; Format formatter; Date date = new Date(); // 01/09/02 formatter = new SimpleDateFormat("MM/dd/yy"); s... formatter = new SimpleDateFormat("dd/MM/yy"); s = formatter.format(date
NSDateformatter format Date
format in iPhone/iPad objective c programming. NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; [formatter setDateFormat:@"yyyy"]; //If you want to set time zone [formatter setTimeZone:[NSTimeZone timeZoneWithName
Simple Date Format Example
; Format formatter; Date date = new Date(); // 01/09/02 formatter = new...); System.out.println(s); // 01/09/02 formatter = new SimpleDateFormat("dd/MM/yy"); s... formatter = new SimpleDateFormat("dd-MMM-yy"); s = formatter.format(date
NSString into the UILabel
NSString into the UILabel  How to display the NSString into the UILabel on UIButton Click?   Find the given code and example that explain to set the NSString value into UILable NSString* str = [formatter
java - Date Calendar
str_date="04-04-2008"; DateFormat formatter ; Date date ; formatter = new SimpleDateFormat("dd-MM-yyyy"); date = (Date
date format - Java Beginners
(); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-mm-dd...(formattedDate); formatter = new SimpleDateFormat("dd-mmm-yyyy"); formattedDate
date format - JSP-Servlet
"; SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); Date dateStr... date1 = formatter.parse(formattedDate); formatter = new SimpleDateFormat
Core - Java Beginners
="24-NOV-08"; DateFormat formatter ; Date date ; formatter = new SimpleDateFormat("dd-MMM-yy"); date = (Date
Iphone Current Time Example
; NSDateFormatter* formatter = [[[NSDateFormatter alloc] init] autorelease...     [formatter setDateFormat:@"HH... = [formatter stringFromDate:date];    
java.text.ParseException: Unparseable date - JSP-Servlet
*; import java.text.*; String strformat="dd-MM-yyy"; SimpleDateFormat formatter... fmtDate = formatter.parse(formattedDate); formatter = new SimpleDateFormat("yyyy
Date Next and Previous - Java Interview Questions
formatter ; Date date ; formatter = new SimpleDateFormat("dd/MM
How to convert String into java.util.Date
"; DateFormat formatter; Date date; formatter = new
java yesterday - Date Calendar
(); SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy"); String
Get Time Now
,Format formatter and  instantiate date class. The Simple Date Format display the time in a specific format as passed in argument  of variable formatter. The variable formatter call a format method ( ) and pass the date object
Spket IDE
efficient JavaScript code. What's new? Spket IDE 1.6.2 JavaScript Formatter
Iphone Show Current Date & Time
it was: [formatter setDateFormat:@"yyyy-MM-dd"]; in date example and in current time, it was written as: [formatter setDateFormat:@"HH:MM:SS"]; Now to print combined result, it should be written like this: [formatter
Objective c date: NSString Date
        NSDateFormatter* formatter...; [formatter setDateFormat:@"yyyy-MM-dd"...* str = [formatter stringFromDate:date];   
Convert Long to Date
() method is a time formatter with the given formatting style for the default locale. And the getTimeInstance(int style) method is used to get the time formatter
Add Years To Date
{ DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy"); Date d=(Date... there. The date as string is then parsed through this formatter and stored
Dateformat Example
: Dateformat Dateformat example Dateformat tutorial Date Formatter
Resource Manager
that extend UIComponent, validator or formatter now have a new resource property


Advertisement null