TimeUnit類常用方法

2021-10-02 07:32:51 字數 1248 閱讀 3210

/* 天 */

timeunit.days;

/* 小時 */

timeunit.hours;

/* 分鐘 */

timeunit.minutes;

/* 秒 */

timeunit.seconds;

/* 毫秒 */

timeunit.milliseconds;

/* 將指定顆粒度的時間轉換為納秒數 */

public long tonanos(long tim);

/* 將指定顆粒度的時間轉換為微秒數 */

public long tomicros(long tim);

/* 將指定顆粒度的時間轉化成毫秒 */

public long tomillis(long tim);

/* 將指定顆粒度的時間轉化成秒 */

public long toseconds(long tim);

/* 將指定顆粒度的時間轉化成分鐘 */

public long tominutes(long tim);

/* 將指定顆粒度的時間轉化成小時 */

public long tohours(long tim);

/* 將指定顆粒度的時間轉化天 */

public long todays(long tim);

/* 將引數顆粒度時間轉換為指定顆粒度時間 */

public long convert(long sourceduration, timeunit sourceunit);

// 5天轉換成小時

system.out.println(timeunit.days.tohours(5));

// 1小時轉換成分鐘

system.out.println(timeunit.hours.tominutes(1));

// 24小時轉換成天

system.out.println(timeunit.hours.todays(24));

// 5天轉換成小時

system.out.println(timeunit.hours.convert(5,timeunit.days));

//延時的用法

new thread(new runnable() catch (interruptedexception e)

}}).start();

Math類常用方法

名稱說明 abs已過載。返回指定數字的絕對值。acos 返回余弦值為指定數字的角度。asin 返回正弦值為指定數字的角度。atan 返回正切值為指定數字的角度。atan2 返回正切值為兩個指定數字的商的角度。bigmul 生成兩個 32 位數字的完整乘積。ceiling 已過載。返回大於或等於指定數...

Graphics類常用方法

名稱 說明 drawarc 畫弧。drawbezier畫立體的貝爾塞曲線。drawbeziers 畫連續立體的貝爾塞曲線。drawclosedcurve 畫閉合曲線。drawcurve 畫曲線。drawellipse畫橢圓。drawimage 畫影象。drawline 畫線。drawpath 通過路...

String 類常用方法

字串 就是由多個字元組成的一串陣列 一旦被複製,就不能被改變 public class stringdemo string s2 new string bys system.out.println s2 s2 system.out.println s2.length s2.length 5 syst...