• java 时区处理机制(0时区转换到服务器时区)


    package com.globalroam.util;
    
    import java.util.Calendar;
    import java.util.Date;
    import java.util.TimeZone;
    
    
    public class TestForPrictice {
        public static void main(String[] args) {
            Calendar cal = Calendar.getInstance();
            TimeZone timeZoneOld = cal.getTimeZone();
        
            
            Date date = new Date(1359641834000L);
            System.out.println(date);
            date = changeTimeZone(date, TimeZone.getTimeZone(timeZoneOld.getDisplayName()), TimeZone.getTimeZone("GMT"));
        }
        
        public static Date changeTimeZone(Date date, TimeZone oldZone, TimeZone newZone) {
            Date dateTmp = null;
            if (date != null) {
                int timeOffset = oldZone.getRawOffset() - newZone.getRawOffset();
                System.out.println("oldZone.getRawOffset()====>" + oldZone.getRawOffset());
                System.out.println("newZone.getRawOffset()====>" + newZone.getRawOffset());
                dateTmp = new Date(date.getTime() - timeOffset);
            }
            return dateTmp;
        }
    }
     js: js 获取客户端时区
    new Date().getTimezoneOffset();
  • 相关阅读:
    poj 3264 Balanced Lineup
    poj 2762 Going from u to v or from v to u?
    hdu 3671 Boonie and Clyde
    zoj 3195 Design the city
    poj 1523 SPF
    Codeforces Polo the Penguin and Matrix
    MVC原理的简述(转)
    C#访问权限修饰符
    XML Schema介绍
    Sql批量删除/插入
  • 原文地址:https://www.cnblogs.com/pyfreshman/p/5016110.html
Copyright © 2020-2023  润新知