Work/Java

Java 13

lagu 2017. 2. 14. 23:23
728x90
반응형

JDK의 유용한 클래스들

- Object 슈퍼 클래스 활용

public boolean equals(Object obj){

boolean rt = false;

if(obj instanceof ObjectSample1){

ObjectSample1 sample = (ObjectSample1) obj;

rt = (sample.getValue() == value);

}

return rt;

}

_instanceof : 객체가 해당 타입이면 true를 아니면 false를 리턴

- 날짜와 관련된 Date & Calendar

날짜를 관리하는 Date 클래스

ex) Date date = new Data();

     date.setTime(nowDate.getTime() - 60 * 60 * 1000);

Date 클래스의 정보를 처리하는 Calendar 클래스

ex) Calendar cal = Calendar.getInstance();

int year = cal.get(Calendar.YEAR);

- 문자열 관련 클래스

StringBuilder 클래스와 StringBuffer 클래스는 둘다 문자열 버퍼링을 제공하는 클래스, StringBuffer클래스는 thread-safe하지만 StringBuilder 클래스는 그렇지 않다. 

싱글 스레드 환경에서는 StringBuilder를 사용해도 무관하며 StringBuilder 클래스가 StringBuffer 클래스보다 더 빠른 성능을 제공

StringTokenizer 클래스는 문자열로부터 토큰을 뽑아내는 기능을 제공

- SimpleDateFormat 클래스

SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMdd HH:mm:ss.SSS",new DateFormatSymbols());

728x90
반응형