'U' specifier seems broken; that string certainly isn' t sortable.
Custom date formatting:
Specifier
Type
Example
Example Output
Dd
Day
{0: dd}
10
Ddd
Day name
{0: ddd}
Tue
Dddd
Full day name
{0: dddd}
Tuesday
F, ff ,...
Second fractions
{0: fff}
932
Gg ,...
Era
{0: gg}
A.D.
Hh
2 digit hour
{0: hh}
10
HH
2 digit hour, 24hr format
{0: HH}
22
Mm
. string (from: currentDate) print (stringDate) // Friday, August 19,201 6
Output date with custom specifier
EEEE: The full name of a day. For example, Monday. 1-3 E stands for short name, for example, Mon.
MMMM: The full name of a month. For example, July. Use 1-3 M to indicate short name, such as Jul.
Dd: the number of digits in a month, such as 07 or 30.
Yyyy: indicates the year represente
(stringdate)//August 19, 2016 Dateformatter.datestyle = DateFormatter.Style.fullStylestringDate = dateformatter.string (from:currentdate) print ( stringdate)//Friday, August 19, 2016
Output date using custom specifiers
Eeee: Represents the full name of a day, such as Monday. Use 1-3 e to represent shorthand, such as Mon.
MMMM: Represents the full name of the one month, such as July. Use 1-3 m to represent shorthand, such as Jul.
) //August19,2016dateFormatter.dateStyle= Dateformatter.style.fullstylestringdate=dateformatter.string (from:currentdate) print ( StringDate) //friday,august19,2016
Output date using custom specifiers
Eeee: Represents the full name of a day, such as Monday. Use 1-3 e to represent shorthand, such as Mon.
MMMM: Represents the full name of the one month, such as July. Use 1-3 m to represent shorthand, such as Jul.
DD: Represents the num
. Percentpositivepattern=1;Console.WriteLine (Val. ToString ("P", MyFormat)); Displays 12.3%;Console.WriteLine (Val. ToString ("P1", MyFormat)); Displays 12.3%;Formatting has a lot of flexibility. The following example shows a meaningless currency structure:Double val=1234567.89;int [] groupsize={2,1,3};Object Myobj=numberformatinfo.currentinfo.clone ();NumberFormatInfo Mycurrency=myobj as NumberFormatInfo;Mycurrency. Currencysymbol= "#"; SymbolMycurrency. Currencydecimalseparator= ":"; Decimal
the specified format provider.
G General Date/Time mode (short time) displays a combination of short date and short time patterns, separated by spaces.
G General Date/Time mode (long time) displays a combination of short date and long time patterns, separated by spaces.
The M or m month-day mode displays the pattern defined by the Datetimeformatinfo.monthdaypattern property associated with the current thread, or the pattern defined by the specified format provider.
The R or R RFC1123 mode displ
In peacetime coding, often to convert the date into a variety of forms of output or hold, today specifically to do a test, found that datetime tostring () method incredibly have so many forms of expression, and everyone to share.DateTime Time=datetime.now; 2010-5-28 11:22:02.4552691 FridayIme. to ("Y") "May 2010"Time. to ("yy") "10"Time. to ("yyy") "2010"Time. to ("yyyy") "2010"Time. to ("Y") "May 2010"Time. To ("M") "May 28"Time. to ("MM") "22"Time.
");
Take a date and get a format like 2005-02-18
DateTime.Now.ToString ("Hh:mm:ss");
Take time to get a format like 10:45:30
Format display
M/d/yy 12/7/58D-mmm 7-decD-mmmm-yy 7-december-58D MMMM 7 DecemberMMMM yy December 58hh:mm TT 08:50 PMH:mm:ss T 8:50:35 Ph:mm 20:50H:mm:ss 20:50:35m/d/yyyy h:mm 12/7/1958 20:50
Character description
(:) T
In peacetime coding, often to convert the date into a variety of forms of output or hold, today specifically to do a test, found that datetime tostring () method incredibly have so many forms of expression, and everyone to share. DateTime Time=datetime.now; 2010-5-28 11:22:02.4552691 FridayIme. to ("Y") "May 2010"Time. to ("yy") "10"Time. to ("yyy") "2010"Time. to ("yyyy") "2010"Time. to ("Y") "May 2010"Time. To ("M") "May 28"Time. to ("MM") "22"Time.
format, without secondsFormat $ (now, "Short Time") Return ValueCustom format parameters: Used to identify the interval of time charactersFormat $ (Time (), "HH: NN") Return Value/Used to identify the interval between date charactersFormat $ (now, "yyyy/mm/DD") Return ValueC format the date and time of the national markFormat $ (now, "C") Return Value 14:56:15Y The day of the yearFormat $ (now, "Y") returns 145D The day of the month (1-366)Format $ (
DateTime.Now.ToString ("Dddd,mmmm,dd, yyyy", new System.Globalization.DateTimeFormatInfo ());//Display date format friday,july, 01,2009 DateTime.Now.ToString ("Dddd,dd mmmm,yyyy" //Output Wednesday, 301 months, 2008 Source: http://msdn.microsoft.com/zh-cn/vstudio/bb762911 (vs.95). aspx, how to: Extract the day of the
Output format for A day in the D month. One-digit date has no leading zeros.DD a day of the month. A one-digit date has a leading zero.The abbreviated name of the day of the DDD week, defined in Abbreviateddaynames.dddd the full name of the day of the week, as defined in DayNames.M-month number. One-digit month has no leading zeros.MM month number. One-digit month has a leading zero.Abbreviated name of the MMM month, defined in AbbreviatedMonthNames.The full name of the
C
Currency
2.5.ToString ("C")
¥2.50
D
Decimal number
25.ToString ("D5")
00025
E
Scientific type
25000.ToString ("E")
2.500000E+005
F
Fixed point
25.ToString ("F2")
25.00
G
Conventional
2.5.ToString ("G")
2.5
N
Digital
2500000.ToString ("N")
2,500,000.00
X
Hexadecimal
255.ToString ("X")
Ff
Number
assumed. // If the year is 20 and the cut-off is 30 then the value will be converted // To 2020; if the year is 40 then this will be converted to 1940. // If no cut-off is supplied then '20' will be pre-pended to the year (YY ). // Output: a string in the format 'yyyy/MM/dd' or'' // Will not attempt to convert certain combinations e.g. DMM, MDD, DDM, YYYYD. Var sParsed, fndSingle; // SParsed will be constructed in the format '
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.