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
F
Full (long date + short time)
dddd, MMMM
a SCSI hard disk, so it is sda and the IED hard disk is hda)
Backup MBR:
# Dd if =/dev/sda of =/boot. NNNN bs = 446 count = 1
Recover MBR:
# Dd if =/boot. NNNN of =/dev/sda bs = 446 count = 1
-Why isn't it 512? The primary Boot Sector is a single sector (512 bytes )?
-Only the first 446 bytes of the backup file boot. NNNN of the primary boot Sector are overwritt
prompt at the terminal, enter:
"DD If=/boot/boot." NNNN Of=/dev/hda bs=446 count=1 "
Note that the BS (buffer
Size) refers to the number of bytes overridden. Why not 512? The primary boot sector is a sector (512 bytes) because we just want to fix the boot or remove Grub/lilo boot of the system MBR through the fan commands instead of restoring the entire primary boot sector. So we just boot the backup file for the main boot sector. The first 446 by
such an API? Let's think about it another way: What software is available under UNIX to get what files the process has opened. If you're experienced enough, it's easy to think of lsof, using it to know which files the process has opened, and what process a file is open to.
OK, let's try a little program to test lsof and see how it gets the files that the process has opened.
/* TESTLSOF.C/
#include
Put the testlsof into the background run, its PID is 3125. Command Lsof-p 3125 to see which file
type, which is 0 if the call succeeds. Later, we'll discuss how to handle the return value as non.
Stored Procedure Descriptionsp_OACreate establish an instance of an automatic action objectsp_OADestroy frees an instance of an objectsp_OAGetErrorInfo Get error description information from the HRESULT returned by other processessp_OAGetProperty store An object's properties in a result set or in a local variablesp_OASetProperty change the value of an object propertysp_OAMethod the method of execu
see which files are open in process 3125, we use Strace to track lsof runs, and the output is saved in Lsof.strace:
# gcc Testlsof.c-o testlsof
#./testlsof
[1] 3125
# strace-o Lsof.strace lsof-p 3125
We use "/tmp/foo" as the keyword search output file lsof.strace, the result is only one:
# grep '/tmp/foo ' lsof.strace
Readlink ("/proc/3125/fd/3", "/tmp/foo", 4096) = 8
Originally lsof Clever use of the/proc/nnnn/fd/directory
method of the limit parameter and the final execution result are as follows,
The following uses the cwj birthday of android123 as an example:
"Mm/DD/yy H: MPAA"-> "11/03/87 am""Mmm DD, yyyy H: MPAA"-> "Nov 3, 1987 am""Mmmm DD, yyyy H: MPAA"-> "November 3, 1987 am""E, Mmmm DD, yyyy H: MPAA"-> "Tues, November 3, 1987 am""Eeee, Mmmm DD, yyyy H: MPAA"-> "Tues day, N
GPS Data Format
GPRS (the minimum GPS data format is recommended)
$GPRMC,
1) standard positioning Time (UTC time) Format: time, minute, second (hhmmss. Sss ).
2) Positioning status, A = data available, V = data unavailable.
3) latitude, in the format of ddmm. Mmmm ).
4) latitude differentiation: Northern Hemisphere (n) or Southern Hemisphere (s ).
5) longitude, in the format of "degree score. Score.
6) The longitude is distinguished, East (e) hemisph
Float-type numbers are stored in four bytes in a computer. Compliance with IEEE-754 format standards:
A floating point number consists of three parts:
Symbol. 0 indicates positive, and 1 indicates negative.
The base part uses the binary number to represent the actual value of the floating point number. The base part actually occupies a value of 24 bits, but the maximum bit is always 1. Therefore, the maximum bit is not stored, 23-bit scientific notation in storage.
The index occupies 8-bit binar
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
, 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
Datetimeformatoptions object that embodies the current configuration, we have to get to the configuration object that hosts the relevant config information. As we said above, the configuration object is created by Configurationbuilder, and the original config information is extracted by the corresponding configurationsource. So the correct way to programmatically create a configuration object is to first create a Configurationbuilder object and then register one or more Configurationsource obje
(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}", DT); "3 Mar March" Month String.Format ("{0:d
void Main (string[] args) {SimpleDateFormat Bartdateformat =New SimpleDateFormat ("eeee-mmmm-dd-yyyy");Date date = new Date ();System.out.println (Bartdateformat.format (date));}}
As long as you pass the format string "eee-mmmm-dd-yyyy" to the SimpleDateFormat constructor, we can specify the format we want. You should be able to see that the ASCII character in the format string tells the Format f
"{0: N4}" 123456789 123,456,789.0000"Total: {0: C}" 12345.6789 Total: $12345.68
The commonly used date formats are shown in the following table:
Format description output formatD. Simplified Date Format: MM/dd/yyyyD detailed Date Format: dddd, MMMM dd, yyyyF full format (long date + short time) dddd, MMMM dd, yyyy HH: mmF complete date and time Format (long date + long time) dddd,
}" 12345.6789 12346"{0: g}" 12345.6789 12345.6789"{0: G7}" 123456789 1.234568e8"{0: n}" 12345.6789 12,345.68"{0: N4}" 123456789 123,456,789.0000"Total: {0: c}" 12345.6789 total: $12345.68
The commonly used date formats are shown in the following table:
Format description output formatD. Simplified Date Format: mm/DD/YYYYD detailed Date Format: dddd, Mmmm DD, yyyyF full format (long date + short time) dddd, Mmmm
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.