ImapUtilsGetDateTimeFromImapDate Method |
Converts the datetime string in IMAP4 format into
DateTime value.
Namespace: MailBee.ImapMailAssembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax public static DateTime GetDateTimeFromImapDate(
string dateTimeString
)
Public Shared Function GetDateTimeFromImapDate (
dateTimeString As String
) As DateTime
Parameters
- dateTimeString
- Type: SystemString
The datetime string in IMAP4 format (can contain: date; date and time; date, time, and timezone).
Return Value
Type:
DateTimeThe
DateTime value representing the parsed IMA4 datetime string, or
MinValue if the
specified datetime string could not be parsed.
Exceptions Remarks The returned date is in UTC (GMT) time. To convert it into local time, the developer can use
ToLocalTime method.
Examples
This sample parses a few IMAP4 datetime strings into
DateTime structures
and prints the results as UTC time and local time.
using System;
using MailBee;
using MailBee.ImapMail;
class Sample
{
static void Main(string[] args)
{
DateTime dt;
string dtString;
dtString = "08-Sep-2004 13:47:32 -0400";
Console.WriteLine(dtString);
dt = ImapUtils.GetDateTimeFromImapDate(dtString);
Console.WriteLine("UTC time: " + dt);
Console.WriteLine("Local time: " + dt.ToLocalTime());
Console.WriteLine();
dtString = "20-May-2005 00:47:32";
Console.WriteLine(dtString);
dt = ImapUtils.GetDateTimeFromImapDate(dtString);
Console.WriteLine("UTC time: " + dt);
Console.WriteLine("Local time: " + dt.ToLocalTime());
Console.WriteLine();
dtString = "31-Jan-2005";
Console.WriteLine(dtString);
dt = ImapUtils.GetDateTimeFromImapDate(dtString);
Console.WriteLine("UTC time: " + dt);
Console.WriteLine("Local time: " + dt.ToLocalTime());
}
}
Imports System
Imports MailBee
Imports MailBee.ImapMail
Module Sample
Sub Main(ByVal args As String())
Dim dt As DateTime
Dim dtString As String
dtString = "08-Sep-2004 13:47:32 -0400"
Console.WriteLine(dtString)
dt = ImapUtils.GetDateTimeFromImapDate(dtString)
Console.WriteLine("UTC time: " & dt)
Console.WriteLine("Local time: " & dt.ToLocalTime())
Console.WriteLine()
dtString = "20-May-2005 00:47:32"
Console.WriteLine(dtString)
dt = ImapUtils.GetDateTimeFromImapDate(dtString)
Console.WriteLine("UTC time: " & dt)
Console.WriteLine("Local time: " & dt.ToLocalTime())
Console.WriteLine()
dtString = "31-Jan-2005"
Console.WriteLine(dtString)
dt = ImapUtils.GetDateTimeFromImapDate(dtString)
Console.WriteLine("UTC time: " & dt)
Console.WriteLine("Local time: " & dt.ToLocalTime())
End Sub
End Module
See Also