Dec 4, 2013

[android] How to Get Current Time



long now = System.currentTimeMillis();


Date date = new Date(now);


SimpleDateFormat CurDateFormat = new SimpleDateFormat("yyyy년 MM월 dd일");
SimpleDateFormat CurTimeFormat = new SimpleDateFormat("HH시 mm분");
SimpleDateFormat CurYearFormat = new SimpleDateFormat("yyyy");
SimpleDateFormat CurMonthFormat = new SimpleDateFormat("MM");
SimpleDateFormat CurDayFormat = new SimpleDateFormat("dd");
SimpleDateFormat CurHourFormat = new SimpleDateFormat("HH");
SimpleDateFormat CurMinuteFormat = new SimpleDateFormat("mm");

String strCurDate = CurDateFormat.format(date);
String strCurTime = CurTimeFormat.format(date);
String strCurYear = CurYearFormat.format(date);
String strCurMonth = CurMonthFormat.format(date);
String strCurDay = CurDayFormat.format(date);
String strCurHour = CurHourFormat.format(date);
String strCurMinute = CurMinuteFormat.format(date);


No comments:

Post a Comment