2014-09-06 3 views
0

두 개의 문자열 (하나에는 날짜가 있고 다른 하나에는 시간이 있음)을 달력 형식으로 변환 할 수 있습니까? 나는 안드로이드 개발에 익숙하지 않다. 내가 틀린 질문을하고 있는지 말해줘. 미리 감사드립니다. 당신이 날짜로 변환 할 필요가두 문자열을 달력 형식으로 변환

String txtDate = (String) txtDisplayDate.getText(); 
String txtTime = (String) txtDisplayTime.getText(); 

답변

2

먼저 당신은 할 수있는 등 같은 :

SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd",Locale.ENGLISH); 
Date dateTxtDate = dateformat .parse(txtDate); 

Date dateTxtTime = dateformat .parse(txtTime); 

Calendar calendar = Calendar.getInstance(); 
calendar.setTime(dateTxtDate); 

calendar.set(Calendar.HOUR_OF_DAY, dateTxtTime.getHours()); 
calendar.set(Calendar.MINUTE,dateTxtTime.getMinutes()); 
calendar.set(Calendar.SECOND,dateTxtTime.getSeconds()); 
관련 문제