Why new Date() was deprecated in JAVA?

Tags:

Here is the answer:

import java.util.Calendar;
import java.util.Date;
import java.util.Locale;

import java.text.DateFormat;

public class UsingCalendar {

public static void main(String[] args) {

Calendar calendar = Calendar.getInstance();
DateFormat df = DateFormat.getDateTimeInstance( DateFormat.FULL, DateFormat.FULL, Locale.KOREAN );

System.out.println( df.format(calendar.getTime()) );

}
}

output:

2002년 7월 30일 화요일 오전 03시46분56초 KST

Press any key to continue…

Can you point out differences between new Date() and Calendar.getInstance().getTime()? Date class was only for american_america. But encapsuling formatting of Calendar makes i18n real.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *