zoukankan      html  css  js  c++  java
  • Java获取网络时间

    try {
               URL url = new URL("http://www.bjtime.cn");// 取得资源对象
                URLConnection uc = url.openConnection();// 生成连接对象
                uc.connect(); // 发出连接
                long ld = uc.getDate(); // 取得网站日期时间
                Date date = new Date(ld); // 转换为标准时间对象
                Calendar calendar = Calendar.getInstance();
                calendar.setTime(date);
                int day = calendar.get(Calendar.DAY_OF_MONTH);
                if (day == 6) {
                    return true;
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
  • 相关阅读:
    @atcoder
    @loj
    @AGC037
    @uoj
    @uoj
    @loj
    @loj
    @loj
    @loj
    @loj
  • 原文地址:https://www.cnblogs.com/xuewater/p/2941889.html
Copyright © 2011-2022 走看看