The main use of the class: Java.text.DecimalFormat
1. To instantiate an object, you can use the following two methods:
Copy Code code as follows:
DecimalFormat df= (DecimalFormat) numberformat.getinstance ();
DecimalFormat df1=
Var s:string;Begin Parameter 1 of formatfloat is a String format instruction, and parameter 2 is a real number type Extended S: = Formatfloat (' ###.### ', 12.3456); return: 12.346 S: = Formatfloat (' 000.000 ', 12.3456); return: 012.346 S: =
JDK5.0 allows you to format the output directly using the printf () method as C, and provides a number of parameters to format the input, and the invocation is simple:
System.out.format ("Pi is approximately%f", Math.PI);
System.out.printf ("Pi is
Datetime. tostring ()There are four overload functions. Generally, it is the one with no parameters. However,Datetime. tostring (string format)More powerful, can output dates of different formats. The following lists some cases for your reference.
C ++ format the output floating point number
Copy codeThe Code is as follows: # include
Using std: cout;
Using std: endl;
Using std: fixed;
Using std: scientific;
Int main ()
{
Double x = 0.001234567;
Double y = 1.946e9;
Cout Cout Cout Return
This is a created
article in which the information may have evolved or changed.
First day:
Package MainImport (Listen and listen to the "FMT"Listen, listen, listen, "time.")Func Main () {Listen and listen to day: = time. Now (). Weekday
Each output stream has a precision member function, and once the precision function is called for an output stream, a number with a decimal point is printed to the stream, either a total of two digits are retained or two bits are retained after the
This article mainly introduces the SQL time format output, convert function application, the need for friends can refer to the
This article mainly introduces the SQL time format output, convert function application, the need for friends can
On the code, see the results:/** @ (#) Testdecimalformat.java 1.0 June 26, 2012** Copyright (c) 2010-2015. All Rights Reserved. Technology company LTD.*/Package com.***.**.***;Import Java.text.DecimalFormat;/*** Add description** @auther Sunyong*
Package CN. Date;
Import Java.text.Format; Import Java.text.SimpleDateFormat; Import Java.util.Date;
/*
*dateformat is an abstract class of date/time format subclasses, because he is an abstract class, so there should be a concrete construction
Looks like StringStream's way faster than sprintf.
Run the test case 10 million times, the gap is about 10 times times.
The use of StringStream
A
A >> a string
The function obtained through the Str method is a string corresponding
Original address: http://cheelooren.blog.hexun.com/2005724_d.html
In our struts application, if the Bean:write output is large double data, by default it is represented by scientific notation such as 1.316E8.
We need to format him, such as the
Vars:string;BeginDirective typeS: = Format (' Max integer is:%d; the smallest integer is:%d ', [Maxint,low (integer)]);Return: The largest integer is: 2147483647; The smallest integer is:-2147483648{Hint: Format directives must start with%,
1. Integer
Int A = 10; decimal, formatted output: % I
Int B = 0743;, formatted output: % o % # O (output leading symbol 0)
Int c = 0x7f3d; hexadecimal format, formatted output: % x % # X (output leading symbol 0x)
2. Floating Point
Float F = 1.234;
In the process of learning the basic Python tutorial, we will generally deal with the basics of strings, lists, tuples, dictionaries and so on, and then we'll take a look at the examples of strings, lists, tuples, and dictionaries as Follows:one,
Seven. Output1. What is output?
The transmission of energy, signals, etc. from a mechanism or device.
2. Our common output:3. Output form in the program:# Print -----> is actually output from the consolePrint (' Hello World ')Print ('
1. Formatted output uses string concatenation to form a template: This leads to formatted output: (Personal business Card making) use of formatted output: The% placeholder S is the character, and D represents the number%s%d%r??? The first format:
Regular | string
No matter what type of application you create, you need to use a string. Regardless of how the data is stored, end users always have to deal with readable text. So, knowing how to use strings is any. NET developers need to learn the
(1) Character test functionIsalnum (test whether the character is an English letter or a number) Isalpha (test character is an English letter) Isascii (test character is ASCII character) Isblank (test character is a space character) Iscntrl ( Test
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.