Nevron Open Vision Documentation
Nevron.Nov Namespace / NTimeZone Class / SafeConvertTime Method
The date and time to convert.
The time zone of dateTime.
The time zone to convert dateTime to.
Determines whether to check if the given date time kind matches the specified source time zone.


In This Topic
    SafeConvertTime Method
    In This Topic
    Safely converts a time from one time zone to another. If the dateTime is an invalid time (that is, it represents a time that does not exist because of a time zone's adjustment rules), then this method rounds it to the nearest valid date time instead of throwing an exception.
    Syntax
    'Declaration
     
    
    Public Shared Function SafeConvertTime( _
       ByVal dateTime As System.Date, _
       ByVal sourceTimeZone As NTimeZone, _
       ByVal destinationTimeZone As NTimeZone, _
       ByVal validateSourceTimeZone As System.Boolean _
    ) As System.Date
    'Usage
     
    
    Dim dateTime As System.Date
    Dim sourceTimeZone As NTimeZone
    Dim destinationTimeZone As NTimeZone
    Dim validateSourceTimeZone As System.Boolean
    Dim value As System.Date
     
    value = NTimeZone.SafeConvertTime(dateTime, sourceTimeZone, destinationTimeZone, validateSourceTimeZone)
    public static System.DateTime SafeConvertTime( 
       System.DateTime dateTime,
       NTimeZone sourceTimeZone,
       NTimeZone destinationTimeZone,
       System.bool validateSourceTimeZone
    )

    Parameters

    dateTime
    The date and time to convert.
    sourceTimeZone
    The time zone of dateTime.
    destinationTimeZone
    The time zone to convert dateTime to.
    validateSourceTimeZone
    Determines whether to check if the given date time kind matches the specified source time zone.
    Requirements

    Target Platforms: Windows 11, Windows 10, Windows 7, Windows Server 2019, Windows Server 2016, Windows Server 2012 R2, Windows Server 2012, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later)

    See Also