자바(JAVA) 형 변환(String과 Date)



String to Date


String from = "2013-04-08 10:10:10";

SimpleDateFormat transFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

Date to = transFormat.parse(from);




Date to String


Date from = new Date();

SimpleDateFormat transFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

String to = transFormat.format(from);


자바(JAVA) 형 변환(String과 int)



Strinig to int


String from = "123";

int to = Integer.parseInt(from);



int to String


int from = 123;

String to = Integer.toString(from);