The format for the ASP.net format method is:
public string Format (
string format,
Iserviceobjectprovider SP
);
Format refers to the formatting we specify, it has a lot of values, I have to list:
Standard format format formats
D mm/dd/yyyy (2001-3-27)
D dddd, MMMM DD, yyyy such as (March 27, 2001)
F dddd, MMMM dd,
format we want.
The Format method is:
public string Format (
string format,
Iserviceobjectprovider SP
);
Format refers to the formatting we specify, it has a lot of values, I have to list:
Standard format format formats
D mm/dd/yyyy (2001-3-27)
D dddd, MMMM DD, yyyy such as (March 27, 2001)
F dddd, MMMM dd,
references the cultureinfo. invariantculture attribute and follows the custom mode "DDD, DD mmmm yyyy hh: mm: SS g \ MT ". Note that "M" in "GMT" requires an escape character, so it is not interpreted.S: sorted date/time mode. ISO 8601 is used to display the mode defined by the datetimeformatinfo. sortabledatetimepattern attribute associated with the current thread or the mode defined by the provider in th
String time = system. datetime. Now. tostring ("yyyy-mm-dd hh: mm: SS ");
Below are some common date and time display formats
Standard formatD mm/DD/YYYY, for example (2001-3-27)D dddd, Mmmm DD, and YYYY, for example, March 27, 2001)F dddd, Mmmm DD,
number can be converted back to the same number after being converted into a string
X or x Hex hexadecimal format
Example:
Static void Main ()
{
Int I = 12345;
Console. WriteLine ("{0: C}", I); // currency
Console. WriteLine ("{0: D}", I); // decimal number
Console. WriteLine ("{0: E}", I); // method of science and technology
Console. WriteLine ("{0: F}", I); // floating point representation
Console. WriteLine ("{0: G}", I); // G or g General common format
Console. WriteLine ("{0: N}", I); // N
31241376000000000l, it indicates the time for Friday, January 1, and twelve o'clock A.M. Ticks always Increments at an interval of 100 nanoseconds.
The datetime value is represented by the standard or custom method stored in the datetimeformatinfo instance. To modify the date display mode, the datetimeformatinfo instance must be writable so that we can write the custom format and store it in the attribute.
Using system. Globalization;
Public class datesapp{Public static void main (string
, and then uses the GetTime method to get the current time, but notice that the output is indeed a string of long integer numbers, which is why? In fact, this is the system based on the current time calculation of a long type of number, as to how the calculation is not described in this article, then how to show the correct time? This is going to take advantage of the DateFormat class above, this class is a base class, it has a subclass is SimpleDateFormat, the concrete usage see the following c
Convert the DateTime data type also contains a Format method and a ToString method that return a string-formatted representatio N of the original value. The format method can is used to Format a value in one of fifteen common ways, while the ' ToString ' can only be used To the format a value in one way.
The Format method takes the following form, where XXX is the name of the numeric base data-type:
Virtual XXX Format (string* format,iserviceobjectprovider* sp)
Similar to the Format methods fo
Reference
DateTime format encyclopedia in SQL commands
Code in C #:
DateTime mydate = DateTime.Now;
sSQL = "Insert into Article (title,createddate) Values (' New Title ', '" + Mydate.format ("G", NULL) + "");
Format character reference table:
Format character
Description
Default return Format
D
Short Date pattern
Mm/dd/yyyy
D
Long Date Pattern
dddd, MMMM DD, yyyy
(minute), S (second ), F (second fraction), F (second fraction, trailing zeroes, are trimmed), t (p.m or a.m) and Z (time zone).
Following examples demonstrate how are the format specifiers rewritten to the output.
Create Date Time 2008-03-09 16:05:07.123 datetime dt = new DateTime (2008, 3, 9, 16, 5, 7, 123); String.Format ("{0:y yy yyy yyyy}", DT); "8 008 2008" Year String.Format ("{0:m MM MMM MMMM}",
. TryParse (S4, out CurrentValue)); Returns True Response.Write (int. TryParse (S5, out CurrentValue)); returns false } Numeric formatting: If you have decimal and float type number processing, use the post character m or F, such as: decimal d = 12345.67M; float f =3.1415f; Otherwise, the number will be treated as a double type, resulting in a compilation error, if the integer is not plus M. 2. Processing and formatting of lettersprotected void Page_Load (object sender, E
= system. datetime. now;Response. Write (mydt. tostring ("F", mydtfi ));/**//**//**//*This code produces the following output.Format en-US exampleChar value of associated property, if anyD 1/3/2002 M/D/YYYY (shortdatepattern)D Thursday, January 03,200 2 dddd, Mmmm DD, YYYY (longdatepattern)F Thursday, January 03,200 2 AMF Thursday, January 03,200 2 12:00:00 am d
we need.In accordance with the above programming pattern, we have written the following program in a console application. We have created an object of type Configurationbuilder, and calling its Add method adds Configurationprovider is an object of type Memoryconfigurationprovider. As the name implies, Memoryconfigurationprovider uses objects in memory to provide the original configuration information, specifically these original configuration information is saved in an element type of keyvaluep
",
// Long date pattern
"D"-"dddd, MMMM dd, yyyy ",
// Short time pattern
"T"-"h: mm tt ",
// Long time pattern
"T"-"h: mm: ss tt ",
// Long date, short time pattern
"F"-"dddd, MMMM dd, yyyy h: mm tt ",
// Long date, long time pattern
"F"-"dddd, MMMM dd,
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.