您的位置:首页 > 编程语言 > Java开发

The advance of Java -- JFC(Java foundation classes library)(Day01)

2017-12-10 20:54 459 查看
1. System:

①System.currentTimeMills(): Gaining the current system's time in millisecond.

②System.getProperties(): Gaining the configuration information of system.

③System.getProperty(key): Gaining one of the configuration information by key - value.

2. Clone:

①deep clone: will copy a class's reference type and basic type.

②shallow clone: only copy basic type.

3.String:

①trim();Erase space.  

②subString(beginIndex); intercept.

③subString(begin,end); intercept(range)

④String.valueOf(5); other type coverted into String

⑤str.length(); gain length

⑥toUpperCase(); a -> A

⑦endsWith(".txt"); compare with the variable you deliver whether contain the key word '.txt'' at last.

⑧startsWith("ddd"): compare with the variable you deliver whether contain the key word 'ddd" at first.

⑨indexOf("h"); return the position of letter of variable 

⑩split("0") return a Array on the basis of splitting variable according to the character you pass. 

4. StringBuffer/StringBuilder:

saving time when we tend to connect String.

grammar: buf.append();

5. Math:

①random()

②pow()

③round()

6. BigDecimal:

Since double is accuracy. So if we want to calculate, using BigDecimal rather than double.

*If the result is non-repeating infinite decimals: b.divide(b1,2,BigDecimal...);7. Timer/TimerTask:
multithreading

Timer t = new Timer();
t.schedule(mission(TimerTask),delay,span)//millisecond8. Date:
Date date =new Date();
System.out.println(date);
SimpleDateFormat s = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss");
System.out.println(s.format(date));

Calendar c = Calendar.getInstance();
System.out.println(c.get(Calendar.DATE));
System.out.println(c.get(Calendar.DAY_OF_MONTH));
System.out.println(c.get(Calendar.DAY_OF_YEAR));

c.add(Calendar.YEAR, 2);
System.out.println(c.get(Calendar.YEAR));
c.set(Calendar.MONTH, 1);

date = c.getTime();
System.out.println(date);

c.setTime(date);
date = s.parse("2017-03-14 12:10:20");
System.out.println(date);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息