/**
* Unix TimeStamp > Date String 변환
* @param dbTimeStamp
* @return
*/
public static String timeStampToSimepleDateString(String dbTimeStamp){
SimpleDateFormat dateFormat = new SimpleDateFormat ("yy/MM/dd");
SimpleDateFormat timeFormat = new SimpleDateFormat ("HH:mm분");
//Yesterday
Calendar today = Calendar.getInstance ( );
today.add ( Calendar.DATE, -1 );
Date yesterday = today.getTime ( );
String yesDate = dateFormat.format(yesterday);
//Current date
Date now = new Date();
String curDate = dateFormat.format(now);
//MySQL DB TimStamp > JAVA Date
Date unixDate = new Date(1000l*Long.parseLong(dbTimeStamp)) ;
String dbDate = dateFormat.format(unixDate);
if(curDate.equals(dbDate)){ // Current
return timeFormat.format(unixDate);
} else if(yesDate.equals(dbDate)){ //Yesterday
return "어제";
} else { // Another
return dbDate; //yyyy MM dd
}
* Unix TimeStamp > Date String 변환
* @param dbTimeStamp
* @return
*/
public static String timeStampToSimepleDateString(String dbTimeStamp){
SimpleDateFormat dateFormat = new SimpleDateFormat ("yy/MM/dd");
SimpleDateFormat timeFormat = new SimpleDateFormat ("HH:mm분");
//Yesterday
Calendar today = Calendar.getInstance ( );
today.add ( Calendar.DATE, -1 );
Date yesterday = today.getTime ( );
String yesDate = dateFormat.format(yesterday);
//Current date
Date now = new Date();
String curDate = dateFormat.format(now);
//MySQL DB TimStamp > JAVA Date
Date unixDate = new Date(1000l*Long.parseLong(dbTimeStamp)) ;
String dbDate = dateFormat.format(unixDate);
if(curDate.equals(dbDate)){ // Current
return timeFormat.format(unixDate);
} else if(yesDate.equals(dbDate)){ //Yesterday
return "어제";
} else { // Another
return dbDate; //yyyy MM dd
}
댓글 없음:
댓글 쓰기