DateTime.GetDateTimeFormats Metodo
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Converte il valore di questa istanza in tutte le rappresentazioni di stringa supportate dagli identificatori di formato di data e ora standard.
Overload
| Nome | Descrizione |
|---|---|
| GetDateTimeFormats() |
Converte il valore di questa istanza in tutte le rappresentazioni di stringa supportate dagli identificatori di formato di data e ora standard. |
| GetDateTimeFormats(Char) |
Converte il valore di questa istanza in tutte le rappresentazioni di stringa supportate dall'identificatore di formato di data e ora standard specificato. |
| GetDateTimeFormats(IFormatProvider) |
Converte il valore di questa istanza in tutte le rappresentazioni di stringa supportate dagli identificatori di formato di data e ora standard e dalle informazioni di formattazione specifiche delle impostazioni cultura specificate. |
| GetDateTimeFormats(Char, IFormatProvider) |
Converte il valore di questa istanza in tutte le rappresentazioni di stringa supportate dall'identificatore di formato di data e ora standard e dalle informazioni di formattazione specifiche delle impostazioni cultura specificate. |
Commenti
Importante
Non è consigliabile presupporre che più chiamate agli GetDateTimeFormats overload restituiscono dati identici. A seconda dell'overload specifico, i dati restituiti da questo metodo possono cambiare se le impostazioni cultura correnti cambiano, l'utente esegue l'override delle singole impostazioni culturali o si verifica un aggiornamento ai dati culturali del sistema.
GetDateTimeFormats()
Converte il valore di questa istanza in tutte le rappresentazioni di stringa supportate dagli identificatori di formato di data e ora standard.
public:
cli::array <System::String ^> ^ GetDateTimeFormats();
public string[] GetDateTimeFormats();
member this.GetDateTimeFormats : unit -> string[]
Public Function GetDateTimeFormats () As String()
Valori restituiti
Matrice di stringhe in cui ogni elemento è la rappresentazione del valore di questa istanza formattata con uno degli identificatori di formato di data e ora standard.
Esempio
Nell'esempio seguente viene illustrato il DateTime.GetDateTimeFormats() metodo . Visualizza la rappresentazione di stringa di una data utilizzando tutti i possibili formati di data e ora standard nelle impostazioni cultura correnti del computer, che in questo caso è en-US.
let july28 = DateTime(2009, 7, 28, 5, 23, 15, 16)
let july28Formats = july28.GetDateTimeFormats()
// Print out july28 in all DateTime formats using the default culture.
for format in july28Formats do
printfn $"{format}"
DateTime july28 = new DateTime(2009, 7, 28, 5, 23, 15, 16);
string[] july28Formats = july28.GetDateTimeFormats();
// Print out july28 in all DateTime formats using the default culture.
foreach (string format in july28Formats) {
Console.WriteLine(format);
}
Dim july28 As New DateTime(2009, 7, 28, 5, 23, 15, 16)
Dim july28Formats As String()
july28Formats = july28.GetDateTimeFormats()
' Print out july28 in all DateTime formats using the default culture.
For Each format As String In july28Formats
Console.WriteLine(format)
Next
Nell'esempio viene visualizzato l'output seguente:
7/28/2009
7/28/09
07/28/09
07/28/2009
09/07/28
2009-07-28
28-Jul-09
Tuesday, July 28, 2009
July 28, 2009
Tuesday, 28 July, 2009
28 July, 2009
Tuesday, July 28, 2009 5:23 AM
Tuesday, July 28, 2009 05:23 AM
Tuesday, July 28, 2009 5:23
Tuesday, July 28, 2009 05:23
July 28, 2009 5:23 AM
July 28, 2009 05:23 AM
July 28, 2009 5:23
July 28, 2009 05:23
Tuesday, 28 July, 2009 5:23 AM
Tuesday, 28 July, 2009 05:23 AM
Tuesday, 28 July, 2009 5:23
Tuesday, 28 July, 2009 05:23
28 July, 2009 5:23 AM
28 July, 2009 05:23 AM
28 July, 2009 5:23
28 July, 2009 05:23
Tuesday, July 28, 2009 5:23:15 AM
Tuesday, July 28, 2009 05:23:15 AM
Tuesday, July 28, 2009 5:23:15
Tuesday, July 28, 2009 05:23:15
July 28, 2009 5:23:15 AM
July 28, 2009 05:23:15 AM
July 28, 2009 5:23:15
July 28, 2009 05:23:15
Tuesday, 28 July, 2009 5:23:15 AM
Tuesday, 28 July, 2009 05:23:15 AM
Tuesday, 28 July, 2009 5:23:15
Tuesday, 28 July, 2009 05:23:15
28 July, 2009 5:23:15 AM
28 July, 2009 05:23:15 AM
28 July, 2009 5:23:15
28 July, 2009 05:23:15
7/28/2009 5:23 AM
7/28/2009 05:23 AM
7/28/2009 5:23
7/28/2009 05:23
7/28/09 5:23 AM
7/28/09 05:23 AM
7/28/09 5:23
7/28/09 05:23
07/28/09 5:23 AM
07/28/09 05:23 AM
07/28/09 5:23
07/28/09 05:23
07/28/2009 5:23 AM
07/28/2009 05:23 AM
07/28/2009 5:23
07/28/2009 05:23
09/07/28 5:23 AM
09/07/28 05:23 AM
09/07/28 5:23
09/07/28 05:23
2009-07-28 5:23 AM
2009-07-28 05:23 AM
2009-07-28 5:23
2009-07-28 05:23
28-Jul-09 5:23 AM
28-Jul-09 05:23 AM
28-Jul-09 5:23
28-Jul-09 05:23
7/28/2009 5:23:15 AM
7/28/2009 05:23:15 AM
7/28/2009 5:23:15
7/28/2009 05:23:15
7/28/09 5:23:15 AM
7/28/09 05:23:15 AM
7/28/09 5:23:15
7/28/09 05:23:15
07/28/09 5:23:15 AM
07/28/09 05:23:15 AM
07/28/09 5:23:15
07/28/09 05:23:15
07/28/2009 5:23:15 AM
07/28/2009 05:23:15 AM
07/28/2009 5:23:15
07/28/2009 05:23:15
09/07/28 5:23:15 AM
09/07/28 05:23:15 AM
09/07/28 5:23:15
09/07/28 05:23:15
2009-07-28 5:23:15 AM
2009-07-28 05:23:15 AM
2009-07-28 5:23:15
2009-07-28 05:23:15
28-Jul-09 5:23:15 AM
28-Jul-09 05:23:15 AM
28-Jul-09 5:23:15
28-Jul-09 05:23:15
July 28
July 28
2009-07-28T05:23:15.0160000
2009-07-28T05:23:15.0160000
Tue, 28 Jul 2009 05:23:15 GMT
Tue, 28 Jul 2009 05:23:15 GMT
2009-07-28T05:23:15
5:23 AM
05:23 AM
5:23
05:23
5:23:15 AM
05:23:15 AM
5:23:15
05:23:15
2009-07-28 05:23:15Z
Tuesday, July 28, 2009 12:23:15 PM
Tuesday, July 28, 2009 12:23:15 PM
Tuesday, July 28, 2009 12:23:15
Tuesday, July 28, 2009 12:23:15
July 28, 2009 12:23:15 PM
July 28, 2009 12:23:15 PM
July 28, 2009 12:23:15
July 28, 2009 12:23:15
Tuesday, 28 July, 2009 12:23:15 PM
Tuesday, 28 July, 2009 12:23:15 PM
Tuesday, 28 July, 2009 12:23:15
Tuesday, 28 July, 2009 12:23:15
28 July, 2009 12:23:15 PM
28 July, 2009 12:23:15 PM
28 July, 2009 12:23:15
28 July, 2009 12:23:15
July, 2009
July, 2009
Commenti
La matrice di stringhe restituita dal DateTime.GetDateTimeFormats() metodo equivale a combinare le matrici di stringhe restituite da chiamate separate al DateTime.GetDateTimeFormats(Char) metodo con le stringhe di formato standard "d", "D", "f", "F", "g", "m", "o", "s", "t", "T", "u", "U" e "y". Per altre informazioni sugli identificatori di formato standard, vedere Stringhe di formato di data e ora standard.
Ogni elemento del valore restituito viene formattato utilizzando le informazioni delle impostazioni cultura correnti. Per altre informazioni sulla formattazione specifica delle impostazioni cultura per le impostazioni cultura correnti, vedere CultureInfo.CurrentCulture.
Importante
Poiché questo metodo usa dati sensibili alle impostazioni cultura, non è consigliabile presupporre che più chiamate al metodo restituiscono dati identici. I dati restituiti da questo metodo possono cambiare se le impostazioni cultura correnti cambiano, l'utente esegue l'override delle singole impostazioni culturali o si verifica un aggiornamento ai dati culturali del sistema.
Vedi anche
Si applica a
GetDateTimeFormats(Char)
Converte il valore di questa istanza in tutte le rappresentazioni di stringa supportate dall'identificatore di formato di data e ora standard specificato.
public:
cli::array <System::String ^> ^ GetDateTimeFormats(char format);
public string[] GetDateTimeFormats(char format);
member this.GetDateTimeFormats : char -> string[]
Public Function GetDateTimeFormats (format As Char) As String()
Parametri
- format
- Char
Stringa di formato di data e ora standard.
Valori restituiti
Matrice di stringhe in cui ogni elemento è la rappresentazione del valore di questa istanza formattata con l'identificatore format di formato di data e ora standard.
Eccezioni
format non è un carattere di identificatore di formato di data e ora standard valido.
Esempio
Nell'esempio seguente viene illustrato il GetDateTimeFormats(Char) metodo . Visualizza la rappresentazione di stringa di una data usando l'identificatore di formato data estesa ("D") per le impostazioni cultura correnti.
let july28 = DateTime(2009, 7, 28, 5, 23, 15)
// Get the long date formats using the current culture.
let longJuly28Formats =
july28.GetDateTimeFormats 'D'
// Display july28 in all long date formats.
for format in longJuly28Formats do
printfn $"{format}"
// The example displays the following output:
// Tuesday, July 28, 2009
// July 28, 2009
// Tuesday, 28 July, 2009
// 28 July, 2009
DateTime july28 = new DateTime(2009, 7, 28, 5, 23, 15);
// Get the long date formats using the current culture.
string [] longJuly28Formats =
july28.GetDateTimeFormats('D');
// Display july28 in all long date formats.
foreach (string format in longJuly28Formats) {
Console.WriteLine(format);
}
// The example displays the following output:
// Tuesday, July 28, 2009
// July 28, 2009
// Tuesday, 28 July, 2009
// 28 July, 2009
Dim july28 As Date = #7/28/2009 5:23:15#
' Get the long date formats using the current culture.
Dim longJuly28Formats() As String = july28.GetDateTimeFormats("D"c)
' Display july28 in all long date formats.
For Each format As String In longJuly28Formats
Console.WriteLine(format)
Next
' The example displays the following output:
' Tuesday, July 28, 2009
' July 28, 2009
' Tuesday, 28 July, 2009
' 28 July, 2009
Commenti
Il format parametro può essere uno qualsiasi degli identificatori di formato di data e ora standard. Sono inclusi d, D, f, F, g, G, M (o m), O (o o), R (o r), s, t, T, u, U e Y (o y). Per altre informazioni, vedere Stringhe di formato di data e ora standard.
Ogni elemento del valore restituito viene formattato utilizzando le informazioni delle impostazioni cultura correnti. Per altre informazioni sulla formattazione specifica delle impostazioni cultura per le impostazioni cultura correnti, vedere CultureInfo.CurrentCulture.
Importante
Poiché questo metodo usa dati sensibili alle impostazioni cultura, non è consigliabile presupporre che più chiamate al metodo restituiscono dati identici. I dati restituiti da questo metodo possono cambiare se le impostazioni cultura correnti cambiano, l'utente esegue l'override delle singole impostazioni culturali o si verifica un aggiornamento ai dati culturali del sistema.
Vedi anche
Si applica a
GetDateTimeFormats(IFormatProvider)
Converte il valore di questa istanza in tutte le rappresentazioni di stringa supportate dagli identificatori di formato di data e ora standard e dalle informazioni di formattazione specifiche delle impostazioni cultura specificate.
public:
cli::array <System::String ^> ^ GetDateTimeFormats(IFormatProvider ^ provider);
public string[] GetDateTimeFormats(IFormatProvider provider);
member this.GetDateTimeFormats : IFormatProvider -> string[]
Public Function GetDateTimeFormats (provider As IFormatProvider) As String()
Parametri
- provider
- IFormatProvider
Oggetto che fornisce informazioni di formattazione specifiche delle impostazioni cultura su questa istanza.
Valori restituiti
Matrice di stringhe in cui ogni elemento è la rappresentazione del valore di questa istanza formattata con uno degli identificatori di formato di data e ora standard.
Esempio
Nell'esempio seguente viene illustrato il DateTime.GetDateTimeFormats(IFormatProvider) metodo . Visualizza la rappresentazione di stringa di una data utilizzando tutti i possibili formati di data e ora standard per le impostazioni cultura fr-FR.
let july28 = DateTime(2009, 7, 28, 5, 23, 15, 16)
let culture =
System.Globalization.CultureInfo("fr-FR", true)
// Get the short date formats using the "fr-FR" culture.
let frenchJuly28Formats =
july28.GetDateTimeFormats culture
// Display july28 in various formats using "fr-FR" culture.
for format in frenchJuly28Formats do
printfn $"{format}"
DateTime july28 = new DateTime(2009, 7, 28, 5, 23, 15, 16);
IFormatProvider culture =
new System.Globalization.CultureInfo("fr-FR", true);
// Get the short date formats using the "fr-FR" culture.
string [] frenchJuly28Formats =
july28.GetDateTimeFormats(culture);
// Display july28 in various formats using "fr-FR" culture.
foreach (string format in frenchJuly28Formats) {
Console.WriteLine(format);
}
Dim july28 As New DateTime(2009, 7, 28, 5, 23, 15, 16)
Dim culture As New System.Globalization.CultureInfo("fr-FR", True)
Dim july28Formats As String()
' Get the short date formats using the "fr-FR" culture.
july28Formats = july28.GetDateTimeFormats(culture)
' Print out july28 in various formats using "fr-FR" culture.
For Each format As String In july28Formats
Console.WriteLine(format)
Next
Nell'esempio viene visualizzato l'output seguente:
28/07/2009
28/07/09
28.07.09
28-07-09
2009-07-28
mardi 28 juillet 2009
28 juil. 09
28 juillet 2009
mardi 28 juillet 2009 05:23
mardi 28 juillet 2009 5:23
mardi 28 juillet 2009 05.23
mardi 28 juillet 2009 05 h 23
28 juil. 09 05:23
28 juil. 09 5:23
28 juil. 09 05.23
28 juil. 09 05 h 23
28 juillet 2009 05:23
28 juillet 2009 5:23
28 juillet 2009 05.23
28 juillet 2009 05 h 23
mardi 28 juillet 2009 05:23:15
mardi 28 juillet 2009 5:23:15
mardi 28 juillet 2009 05.23
mardi 28 juillet 2009 05 h 23
28 juil. 09 05:23:15
28 juil. 09 5:23:15
28 juil. 09 05.23
28 juil. 09 05 h 23
28 juillet 2009 05:23:15
28 juillet 2009 5:23:15
28 juillet 2009 05.23
28 juillet 2009 05 h 23
28/07/2009 05:23
28/07/2009 5:23
28/07/2009 05.23
28/07/2009 05 h 23
28/07/09 05:23
28/07/09 5:23
28/07/09 05.23
28/07/09 05 h 23
28.07.09 05:23
28.07.09 5:23
28.07.09 05.23
28.07.09 05 h 23
28-07-09 05:23
28-07-09 5:23
28-07-09 05.23
28-07-09 05 h 23
2009-07-28 05:23
2009-07-28 5:23
2009-07-28 05.23
2009-07-28 05 h 23
28/07/2009 05:23:15
28/07/2009 5:23:15
28/07/2009 05.23
28/07/2009 05 h 23
28/07/09 05:23:15
28/07/09 5:23:15
28/07/09 05.23
28/07/09 05 h 23
28.07.09 05:23:15
28.07.09 5:23:15
28.07.09 05.23
28.07.09 05 h 23
28-07-09 05:23:15
28-07-09 5:23:15
28-07-09 05.23
28-07-09 05 h 23
2009-07-28 05:23:15
2009-07-28 5:23:15
2009-07-28 05.23
2009-07-28 05 h 23
28 juillet
28 juillet
2009-07-28T05:23:15.0160000
2009-07-28T05:23:15.0160000
Tue, 28 Jul 2009 05:23:15 GMT
Tue, 28 Jul 2009 05:23:15 GMT
2009-07-28T05:23:15
05:23
5:23
05.23
05 h 23
05:23:15
5:23:15
05.23
05 h 23
2009-07-28 05:23:15Z
mardi 28 juillet 2009 12:23:15
mardi 28 juillet 2009 12:23:15
mardi 28 juillet 2009 12.23
mardi 28 juillet 2009 12 h 23
28 juil. 09 12:23:15
28 juil. 09 12:23:15
28 juil. 09 12.23
28 juil. 09 12 h 23
28 juillet 2009 12:23:15
28 juillet 2009 12:23:15
28 juillet 2009 12.23
28 juillet 2009 12 h 23
juillet 2009
juillet 2009
Commenti
La matrice di stringhe restituita dal DateTime.GetDateTimeFormats(IFormatProvider) metodo equivale a combinare le matrici di stringhe restituite da chiamate separate al DateTime.GetDateTimeFormats(Char, IFormatProvider) metodo con le stringhe di formato standard "d", "D", "f", "F", "g", "m", "o", "s", "t", "T", "u", "U" e "y". Per altre informazioni sugli identificatori di formato standard, vedere Stringhe di formato di data e ora standard.
Ogni elemento del valore restituito viene formattato usando informazioni specifiche delle impostazioni cultura fornite da provider.
Importante
Poiché questo metodo usa dati sensibili alle impostazioni cultura, non è consigliabile presupporre che più chiamate al metodo restituiscano dati identici, a meno provider che non sia un CultureInfo oggetto che rappresenta le impostazioni cultura invarianti. I dati restituiti da questo metodo possono cambiare se l'utente esegue l'override delle singole impostazioni cultura di provider o se si verifica un aggiornamento ai dati culturali del sistema per provider.
Vedi anche
Si applica a
GetDateTimeFormats(Char, IFormatProvider)
Converte il valore di questa istanza in tutte le rappresentazioni di stringa supportate dall'identificatore di formato di data e ora standard e dalle informazioni di formattazione specifiche delle impostazioni cultura specificate.
public:
cli::array <System::String ^> ^ GetDateTimeFormats(char format, IFormatProvider ^ provider);
public string[] GetDateTimeFormats(char format, IFormatProvider provider);
member this.GetDateTimeFormats : char * IFormatProvider -> string[]
Public Function GetDateTimeFormats (format As Char, provider As IFormatProvider) As String()
Parametri
- format
- Char
Stringa di formato data e ora.
- provider
- IFormatProvider
Oggetto che fornisce informazioni di formattazione specifiche delle impostazioni cultura su questa istanza.
Valori restituiti
Matrice di stringhe in cui ogni elemento è la rappresentazione del valore di questa istanza formattata con uno degli identificatori di formato di data e ora standard.
Eccezioni
format non è un carattere di identificatore di formato di data e ora standard valido.
Esempio
Nell'esempio seguente viene illustrato il GetDateTimeFormats(Char, IFormatProvider) metodo . Visualizza le rappresentazioni di stringa di una data usando l'identificatore di formato data breve ("d") per le impostazioni cultura fr-FR.
let july28 = DateTime(2009, 7, 28, 5, 23, 15)
let culture =
System.Globalization.CultureInfo("fr-FR", true)
// Get the short date formats using the "fr-FR" culture.
let frenchJuly28Formats =
july28.GetDateTimeFormats('d', culture)
// Display july28 in short date formats using "fr-FR" culture.
for format in frenchJuly28Formats do
printfn $"{format}"
// The example displays the following output:
// 28/07/2009
// 28/07/09
// 28.07.09
// 28-07-09
// 2009-07-28
DateTime july28 = new DateTime(2009, 7, 28, 5, 23, 15);
IFormatProvider culture =
new System.Globalization.CultureInfo("fr-FR", true);
// Get the short date formats using the "fr-FR" culture.
string [] frenchJuly28Formats =
july28.GetDateTimeFormats('d', culture);
// Display july28 in short date formats using "fr-FR" culture.
foreach (string format in frenchJuly28Formats) {
Console.WriteLine(format);
}
// The example displays the following output:
// 28/07/2009
// 28/07/09
// 28.07.09
// 28-07-09
// 2009-07-28
Dim july28 As Date = #7/28/2009 5:23:15#
Dim culture As IFormatProvider = New System.Globalization.CultureInfo("fr-FR", True)
' Get the short date formats using the "fr-FR" culture.
Dim frenchJuly28Formats() As String = july28.GetDateTimeFormats("d"c, culture)
' Display july28 in short date formats using "fr-FR" culture.
For Each format As String In frenchJuly28Formats
Console.WriteLine(format)
Next
' The example displays the following output:
' 28/07/2009
' 28/07/09
' 28.07.09
' 28-07-09
' 2009-07-28
Commenti
Il parametro format può essere uno qualsiasi degli identificatori di formato di data e ora standard. Sono inclusi d, D, f, F, g, G, M (o m), O (o o), R (o r), s, t, T, u, U e Y (o y). Per altre informazioni, vedere Stringhe di formato di data e ora standard.
Ogni elemento del valore restituito viene formattato usando informazioni specifiche delle impostazioni cultura fornite da provider.
Importante
Poiché questo metodo usa dati sensibili alle impostazioni cultura, non è consigliabile presupporre che più chiamate al metodo restituiscano dati identici, a meno provider che non sia un CultureInfo oggetto che rappresenta le impostazioni cultura invarianti. I dati restituiti da questo metodo possono cambiare se l'utente esegue l'override delle singole impostazioni cultura di provider o se si verifica un aggiornamento ai dati culturali del sistema per provider.