……天天向上

          好的想法總是無窮無盡

          統計

          留言簿(1)

          閱讀排行榜

          評論排行榜

          2012年9月10日 #

          calendar獲取當前日期及時間的用例

          1. import Java.util.*;
          2.   public class ShowDate {
          3.   public static void main(String[] args) {
          4.   Calendar calendar = new GregorianCalendar();
          5.   Date trialTime = new Date();
          6.   calendar.setTime(trialTime);
          7.   // print out a bunch of interesting things
          8.   System.out.println("ERA: " + calendar.get(Calendar.ERA));
          9.   System.out.println("YEAR: " + calendar.get(Calendar.YEAR));
          10.   System.out.println("MONTH: " + calendar.get(Calendar.MONTH));
          11.   System.out.println("WEEK_OF_YEAR: " + calendar.get(Calendar.WEEK_OF_YEAR));
          12.   System.out.println("WEEK_OF_MONTH: " + calendar.get(Calendar.WEEK_OF_MONTH));
          13.   System.out.println("DATE: " + calendar.get(Calendar.DATE));
          14.   System.out.println("DAY_OF_MONTH: " + calendar.get(Calendar.DAY_OF_MONTH));
          15.   System.out.println("DAY_OF_YEAR: " + calendar.get(Calendar.DAY_OF_YEAR));
          16.   System.out.println("DAY_OF_WEEK: " + calendar.get(Calendar.DAY_OF_WEEK));
          17.   System.out.println("DAY_OF_WEEK_IN_MONTH: " + calendar.get(Calendar.DAY_OF_WEEK_IN_MONTH));
          18.   System.out.println("AM_PM: " + calendar.get(Calendar.AM_PM));
          19.   System.out.println("HOUR: " + calendar.get(Calendar.HOUR));
          20.   System.out.println("HOUR_OF_DAY: " + calendar.get(Calendar.HOUR_OF_DAY));
          21.   System.out.println("MINUTE: " + calendar.get(Calendar.MINUTE));
          22.   System.out.println("SECOND: " + calendar.get(Calendar.SECOND));
          23.   System.out.println("MILLISECOND: " + calendar.get(Calendar.MILLISECOND));
          24.   System.out.println("ZONE_OFFSET: " + (calendar.get(Calendar.ZONE_OFFSET)/(60*60*1000)));
          25.   System.out.println("DST_OFFSET: " + (calendar.get(Calendar.DST_OFFSET)/(60*60*1000)));
          26.   System.out.println("Current Time, with hour reset to 3");
          27.   calendar.clear(Calendar.HOUR_OF_DAY); // so doesn't override
          28.   calendar.set(Calendar.HOUR, 3);
          29.   System.out.println("ERA: " + calendar.get(Calendar.ERA));
          30.   System.out.println("YEAR: " + calendar.get(Calendar.YEAR));
          31.   System.out.println("MONTH: " + calendar.get(Calendar.MONTH));
          32.   System.out.println("WEEK_OF_YEAR: " + calendar.get(Calendar.WEEK_OF_YEAR));
          33.   System.out.println("WEEK_OF_MONTH: " + calendar.get(Calendar.WEEK_OF_MONTH));
          34.   System.out.println("DATE: " + calendar.get(Calendar.DATE));
          35.   System.out.println("DAY_OF_MONTH: " + calendar.get(Calendar.DAY_OF_MONTH));
          36.   System.out.println("DAY_OF_YEAR: " + calendar.get(Calendar.DAY_OF_YEAR));
          37.   System.out.println("DAY_OF_WEEK: " + calendar.get(Calendar.DAY_OF_WEEK));
          38.   System.out.println("DAY_OF_WEEK_IN_MONTH: " + calendar.get(Calendar.DAY_OF_WEEK_IN_MONTH));

          posted @ 2012-09-19 09:51 japper 閱讀(6354) | 評論 (0)編輯 收藏

          Android SDK下載和更新失敗的解決方法


          Android SDK下載和更新失敗的解決方法

           

          最近剛換了電腦,開始搭建Android開發環境的時候,下載SDK總是會出現如下錯誤:
           
          1.Failed to fetch URL http://dl-ssl.google.com/Android/repository/addons_list-1.xml
          據說dl-ssl.google.com在大陸被強了,偉大的天朝真是不讓人活了,解決方法就是修改C:\Windows\System32\drivers\etc\hosts文件。添加一行:
           
          1.74.125.237.1       dl-ssl.google.com 
          這里需要注意的是hosts文件是只讀的,我們沒有權限修改,需要我們將hosts文件復制到桌面或者其他地方,然后修改,代碼如下:
          1.# Copyright (c) 1993-2009 Microsoft Corp. 
          2.# 
          3.# This is a sample HOSTS file used by Microsoft TCP/IP for Windows. 
          4.# 
          5.# This file contains the mappings of IP addresses to host names. Each 
          6.# entry should be kept on an individual line. The IP address should 
          7.# be placed in the first column followed by the corresponding host name. 
          8.# The IP address and the host name should be separated by at least one 
          9.# space. 
          10.# 
          11.# Additionally, comments (such as these) may be inserted on individual 
          12.# lines or following the machine name denoted by a '#' symbol. 
          13.# 
          14.# For example: 
          15.# 
          16.#      102.54.94.97     rhino.acme.com          # source server 
          17.#       38.25.63.10     x.acme.com              # x client host 
          18. 
          19.# localhost name resolution is handled within DNS itself. 
          20.#   127.0.0.1       localhost 
          21.#   ::1             localhost 
          22.//親,就是增加這一句哦  
          23.74.125.237.1       dl-ssl.google.com 
          然后保存,復制修改后的hosts文件到C:\Windows\System32\drivers\etc 目錄,替換文件就好!??!我們再次下載SDK的時候就會成功啦,如下圖:
           


          嘿嘿,大功告成啦?。?!
           
          PS:補充下,在mac或Linux中,hosts文件所在位置為/etc/hosts,可以使用sudo vim /etc/hosts來編輯。

          posted @ 2012-09-10 11:18 japper 閱讀(349) | 評論 (0)編輯 收藏

          主站蜘蛛池模板: 隆子县| 双流县| 河西区| 安庆市| 桦甸市| 罗江县| 双城市| 康马县| 沁水县| 白朗县| 抚宁县| 广宁县| 宁强县| 万山特区| 柯坪县| 波密县| 阳江市| 利川市| 昌邑市| 平潭县| 和顺县| 屏东县| 安岳县| 平阴县| 东辽县| 曲松县| 威海市| 阿合奇县| 成都市| 龙泉市| 孟连| 江西省| 开远市| 江阴市| 南充市| 印江| 和林格尔县| 平果县| 洛扎县| 区。| 喀喇|