⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 course4.htm

📁 java函数速查中文版该文件为网页形式,轻重包含了java中的大多数类的说明,及类中方法的介绍,对初学者非常实用.
💻 HTM
📖 第 1 页 / 共 5 页
字号:
<p>返回代表新时间的Time对象。</p>
<p class="title_2">说明</p>
<p>Time对象不能被修改。可以使用add方法创建新的Time对象,该新Time对象的日期和时</p>
<p>间都是根据当前的Time对象得来的,但增加interval所指定数量的时间单位。</p>
<p>下面的例子演示了如何使用add方法创建新的Time对象,该新的Time对象比初始化为当前</p>
<p>时间的Time对象晚两个小时。</p>
<p>public void AddTwoHours ()</p>
<pre>{
    // Create object that is set to current time
    Time now = new Time () ;
    //Output the current time
    System.out.println("The current time is;"+now.toString() ) ;
    //Increment the current time by two hours
   Time twoHoursLater = now.add ( Time.UNITS_PER_HOUR * 2 ) ;
    //Output the time
    System.out.println ("The time two hours from now ig"+twoHoursLater.toString() );
}</pre>
<p>请参阅:Time.UNITS_PER_HOUR</p>
<p>Time.addDays</p>
<p>创建新的Time对象,代表该Time对象之后数天的时间。</p>
<p class="title_2">语法</p>
<p>public Time addDays( double interval )</p>
<p>public Time addDays ( int interval )</p>
<p class="title_2">参数</p>
<p>interval</p>
<p>一个整数值,代表给当前时间所增加的天数。</p>
<p class="title_2">返回值</p>
<p>返回代表新时间的Time对象。</p>
<p class="title_2">说明</p>
<p>Time对象不能被修改。可以使用addDays方法创建新的Time对象,该新Time对象的日期</p>
<p>和时间都是根据当前的Time对象得来的,但增加interval所指定数量的天数。</p>
<p>下面的例子演示了如何使用addDays方法创建新的Time对象,该新的Time对象比初始化为</p>
<p>当前日期的Time对象晚两天。</p>
<p>public void AddTwoDays ()</p>
<pre>{
    // Create object that is set to current date
    Time now = new Time () ;
    //Output the current date
    System.out.println("The current date is:"+now.formatShortDate() ) ;
    //Increment the current time by two days
    Time twoDaysLater = now.addDays( 2 ) ;
    //Output the time
    System.out.println ("The date two days from now is;"+twoDaysLater.formatShortDate()  )  ;
}</pre>
<p>请参阅:formatShortDate, addMonths, addYears</p>
<p>Time.addHours</p>
<p>创建新的Time对象,代表该Time对象之后数小时的时间。</p>
<p class="title_2">语法</p>
<p>public Time addHours( long interval )</p>
<p class="title_2">参数</p>
<p>interval</p>
<p>一个整数值,代表给当前时间所增加的小时数。</p>
<p class="title_2">返回值</p>
<p>返回代表新时间的Time对象。</p>
<p class="title_2">说明</p>
<p>Time对象不能被修改。可以使用addHours方法创建新的Time对象,该新Time对象的日期</p>
<p>和时间都是根据当前的Time对象得来的,但增加interval所指定数量的小时数。</p>
<p>下面的例子演示了如何使用addHours方法创建新的Time对象,该</p>
<p>新的Time对象比初始化为当前日期的Time对象晚两小时。</p>
<p>public void AddTwoHours ()</p>
<pre>{
    // Create object that is set to current time
    Time now = new Time () ;
    //Output the current time
    System.out.println("The current time is;"+ now.toString() ) ;
    //Increment the current time by two hours
    Time twoHoursLater = now.addHours( 2 ) ;
    //Output the time
    System.out.println ("The time two hours from now is"+twoHoursLater.formatShortTime() ) ;
}</pre>
<p>请参阅:addMillis, addMinutes, addSeconds, formatShortTime</p>
<p>Time.addMillis</p>
<p>创建新的Time对象,代表该Time对象之后数毫秒的时间。</p>
<p class="title_2">语法</p>
<p>public Time addHours( long interval )</p>
<p class="title_2">参数</p>
<p>interval</p>
<p>一个整数值,代表给当前时间所增加的毫秒数。</p>
<p class="title_2">返回值</p>
<p>返回代表新时间的Time对象。</p>
<p class="title_2">说明</p>
<p>Time对象不能被修改。可以使用addMillis方法创建新的Time对象,该新Time对象的日期</p>
<p>和时间都是根据当前的Time对象得来的,但增加interval所指定数量的毫秒数。</p>
<p>请参阅:addHours, addMinutes, addSeconds</p>
<p>Time.addMinutes</p>
<p>创建新的Time对象,代表该Time对象之后数分钟的时间。</p>
<p class="title_2">语法</p>
<p>public Time addMinutes( long interval )</p>
<p class="title_2">参数</p>
<p>interval</p>
<p>一个整数值,代表给当前时间所增加的分钟数。</p>
<p class="title_2">返回值</p>
<p>返回代表新时间的Time对象。</p>
<p class="title_2">说明</p>
<p>Time对象不能被修改。可以使用addMinutes方法创建新的Time对象,该新Time对象的日</p>
<p>期和时间都是根据当前的Time对象得来的,但增加interval所指定数量的分钟数。</p>
<p>下面的例子演示了如何使用addMinutes方法创建新的Time对象,该新的Time对象比初始化</p>
<p>为当前日期的Time对象晚30分钟。</p>
<p>public void AddTwoMinutes ()</p>
<pre>{
    // Create object that is set to current time
    Time now = new Time () ;
    //Output the current time
    System.out.println("The current date is;"+ now.toString() ) ;
    //Increment the current time by 30 minutes
    Time thirtyMinutes = now.addMinutes( 30 ) ;
    //Output the time
    System.out.println ("The time 30 minutes from now is;"+ thirtyMinutes.formatShortTime() ) ;
}</pre>
<p>请参阅:addMillis, addHours, addSeconds, formatShortTime</p>
<p>Time.addMonths</p>
<p>创建新的Time对象,代表该Time对象之后数月的时间。</p>
<p class="title_2">语法</p>
<p>public Time addMonths( long interval</p>
<p class="title_2">参数</p>
<p>interval</p>
<p>一个整数值,代表给当前时间所增加的月数。</p>
<p class="title_2">返回值</p>
<p>返回代表新时间的Time对象。</p>
<p class="title_2">说明</p>
<p>Time对象不能被修改。可以使用addMonths方法创建新的Time对象,该新Time对象的日</p>
<p>期和时间都是根据当前的Time对象得来的,但增加interval所指定数量的月数。</p>
<p>下面的例子演示了如何使用addMonths方法创建新的Time对象,该新的Time对象比初始化</p>
<p>为1999年新年的Time对象晚3个月。</p>
<p>public String ReturnFirstQuarter( )</p>
<pre>{
    // Create object that is set to the beginning of 1999
    Time newYears = new Time (1999.01.01) ;
    //Increment the current time by 3 moths
    Time firstQuarter = newYears.addMonths( 3) ;
    Output the date
    return firstQuarter.formatLongDate () ;
}</pre>
<p>请参阅:formatLongDate, addDays, addYears</p>
<p>Time.addSeconds</p>
<p>创建新的Time对象,代表该Time对象之后数秒的时间。</p>
<p class="title_2">语法</p>
<p>public Time addSeconds( long interval )</p>
<p class="title_2">参数</p>
<p>interval</p>
<p>一个整数值,代表给当前时间所增加的秒数。</p>
<p class="title_2">返回值</p>
<p>返回代表新时间的Time对象。</p>
<p class="title_2">说明</p>
<p>Time对象不能被修改。可以使用addSeconds方法创建新的Time对象,该新Time对象的日</p>
<p>期和时间都是根据当前的Time对象得来的,但增加interval所指定数量的秒数。</p>
<p>下面的例子演示了如何使用addSeconds方法创建新的Time对象,该新的Time对象比初始</p>
<p>化为当前日期的Time对象晚30秒。</p>
<p>public void AddThirtySeconds ()</p>
<pre>{
    // Create object that is set to current time
    Time now = new Time () ;
    //Output the current time
    System.out.println("The current time is;"+ now.toString() ) ;
    //Increment the current time by 30 seconds
    Time thirtySeconds = now.addSeconds( 30 ) ;
    //Output the time
    System.out.println ("The time 30 minutes from now is;"+thirtySeconds.formatShortTime() ) ;
}</pre>
<p>请参阅:addMillis, addHours, addMinutes, formatShortTime</p>
<p>Time.addYears</p>
<p>创建新的Time对象,代表该Time对象之后数年的时间。</p>
<p class="title_2">语法</p>
<p>public Time addYears( int interval )</p>
<p class="title_2">参数</p>
<p>interval</p>
<p>一个整数值,代表给当前时间所增加的年数。</p>
<p class="title_2">返回值</p>
<p>返回代表新时间的Time对象。</p>
<p class="title_2">说明</p>
<p>Time对象不能被修改。可以使用addYears方法创建新的Time对象,该新Time对象的日期</p>
<p>和时间都是根据当前的Time对象得来的,但增加interval所指定数量的年数。</p>
<p>下面的例子演示了如何使用addYears方法创建新的Time对象,该</p>
<p>新的Time对象比初始化为当前日期的Time对象晚6年。</p>
<p>public int ReturnMastersYear ()</p>
<pre>{
    // Create object that is set to current date
    Time StartCollege = new Time () ;
    //Increment startCollege by 6 years
    Time endMasters = startCollege.addYears( 6 ) ;
    return endMasters.getYear() ;
}</pre>
<p>请参阅:getYear, addDays, addMonths</p>
<p>Time.compare</p>
<p>比较两个Time对象。</p>
<p class="title_2">语法</p>
<p>public static int compare ( Time t1, Time t2)</p>
<p class="title_2">参数</p>
<p>t1</p>
<p>要比较的第一个Time对象。</p>
<p>t2</p>
<p>要比较的第二个Time对象。</p>
<p class="title_2">返回值</p>
<p>如果t1比t2大,就返回1;如果两个Time对象相等,就返回0;如果t2 比t1大,就返回-1。</p>
<p>请参阅:compareTo, equals</p>
<p>Time.compareTo</p>
<p>将该Time对象与另一个Time对象进行比较。</p>
<p class="title_2">语法</p>
<p>public int compareTo ( Time t )</p>
<p class="title_2">参数</p>
<p>t</p>
<p>要与当前Time对象进行比较的Time对象。</p>
<p class="title_2">返回值</p>
<p>如果t比当前时间大,就返回1;如果两个Time对象相等,就返回0;如果当前Time对象</p>
<p>比t大,就返回-1。</p>
<p>请参阅:compare, equals</p>
<p>Time.equals</p>
<p>检查是否相等。</p>
<p class="title_2">语法</p>
<p>public boolean equals (Object object )</p>
<p class="title_2">参数</p>
<p>object</p>
<p>要比较的对象。</p>
<p class="title_2">返回值</p>
<p>如果object所代表的Time对象与该Time对象相同,就返回true。</p>
<p class="title_2">说明</p>
<p>如果你不能确定某个对象是不是有效的Time对象,就使用该方法。要比较两个已知的Time</p>
<p>对象,使用compare或compareTo方法。</p>
<p>Time.formatLongDate</p>
<p>以使用长日期格式的字符串形式检取Time对象。</p>
<p class="title_2">语法</p>
<p>public String formatLongDate ( )</p>
<p class="title_2">返回值</p>
<p>返回代表长日期格式Time对象的String对象。</p>
<p class="title_2">说明</p>
<p>使用formatLongDate方法从Time对象中抽取一个日期字段。有关如何使用该方法的例子,</p>
<p>请参阅addMonths方法。</p>
<p>请参阅:formatShortDate, formatLongTime</p>
<p>Time.formatLongTime</p>
<p>以使用长时间格式的字符串形式检取Time对象。</p>
<p class="title_2">语法</p>
<p>public String formatLongTime ( )</p>
<p class="title_2">返回值</p>
<p>返回代表长时间格式Time对象的String对象。</p>
<p class="title_2">说明</p>
<p>使用formatLongTmie方法从Time对象中抽取一个时间字段。有关如何使用该方法的例子,</p>
<p>请参阅addSeconds方法。</p>
<p>请参阅:formatShortTime, formatLongDate</p>
<p>Time.formatShortDate</p>
<p>以使用短日期格式的字符串形式检取Time对象。</p>
<p class="title_2">语法</p>
<p>public String formatShortDate ( )</p>
<p class="title_2">返回值</p>
<p>返回代表短日期格式Time对象的String对象。</p>
<p class="title_2">说明</p>
<p>使用formatShortDate方法从Time对象中抽取一个日期字段。有关如何使用该方法的例子,</p>
<p>请参阅addDays方法。</p>
<p>请参阅:formatLongDate, formatShortTime</p>
<p>Time.formatShortTime</p>
<p>以使用短时间格式的字符串形式检取Time对象。</p>
<p class="title_2">语法</p>
<p>public String formatShortTime ( )</p>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -