zoukankan      html  css  js  c++  java
  • UTC时间转换为本地时间 UTCToLocalTime

    function UTCToLocalTime( UTCTime : TDateTime; iTimeZoneBias:integer ): TDateTime;
    var
        LocalSTime, UTCSTime : TSystemTime;
        TZInfo : TTimeZoneInformation;
        PTZInfo : PTimeZoneInformation;
        CalcResult : LongBool;
        LastError : LongInt;
    begin

        GetTimeZoneInformation( TzInfo );
        Tzinfo.bias := Tzinfo.bias + iTimeZoneBias*60;
        PTZInfo := @TZInfo;

        DateTimeToSystemTime( UTCTime, UTCSTime );
        CalcResult := SystemTimeToTzSpecificLocalTime( PTzInfo, UTCSTime,
    LocalSTime );
        if not CalcResult then begin
            LastError := GetLastError;
            raise Exception.Create(SysErrorMessage(LastError));
        end;

        Result := SystemTimeToDateTime( LocalSTime );

    end;

    //主要用到两个重要的函数:

    //  GetTimeZoneInformation;得到时区信息
    //  SystemTimeToTzSpecificLocalTime;根据时区设置本地时间;

  • 相关阅读:
    web.xml模板
    log4j.properties模板
    springmvc-config.xml模板
    applicationContext.xml配置druid连接池
    mybatis-config.xml模板
    mapper.xml模板
    Servlet基础认识
    单例模式的懒汉饿汉
    霜降小悟
    忙闲有致
  • 原文地址:https://www.cnblogs.com/MaxWoods/p/2714606.html
Copyright © 2011-2022 走看看