안녕하세요..
안드로이드 프로그램을 공부하고있는데요..
뭐하나 만들어 볼려구 하는데 이건 영 ㅠ 좀 알려주세요..
내용은..
시작 기준이 되는 년,월,일 입력을 받고.. 100(이것두 입력받고)일 후는
몇년,월,일 인지.. 알려주는걸 해볼려고하는데.. 좀 알려주세요..
이것 저것 검색을 해서 조합을 해보았는데..
현 날짜 기준으로는가능한데..
시작 기준이 되는 날짜를 입력받아서 하는건.. 안되네요..
일단 제가 작성한 코드는..
public class DayPrint extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView dayprint =
(TextView) findViewById(R.id.viewText);
dayprint.setText(getDate(2,2009 ,9 ,2));
}
//iDay 알고싶은 날짜..
//Inyear ,Mmonth,Dday 기준 날짜(시작날짜)
public
String getDate ( int iDay ,int Inyear , int Mmonth , int Dday)
{
Date DDate = new Date (Inyear,Mmonth,Dday);
Calendar
temp=Calendar.getInstance();
temp.setTime(DDate);
StringBuffer
sbDate=new StringBuffer ( );
temp.add ( Calendar.DAY_OF_MONTH, iDay );
int nYear = temp.get ( Calendar.YEAR );
int nMonth = temp.get (
Calendar.MONTH ) + 1;
int nDay = temp.get ( Calendar.DAY_OF_MONTH );
sbDate.append ( nYear );
if ( nMonth < 10 )
sbDate.append ( "0" );
sbDate.append ( nMonth );
if ( nDay < 10
)
sbDate.append ( "0" );
sbDate.append ( nDay );
return sbDate.toString ( );
}
}
출력 : 39091004
이 소스말고 다른 방법이 있으면 부탁합니다.. 수정도 가능하면 수정도 부탁드립니다..




GregorianCalendar gc = new GregorianCalendar();
gc.set(year, month, day);
String today = ""+gc.get(Calendar.YEAR)+"-"+(gc.get(Calendar.MONTH)+1)+"-"+gc.get(Calendar.DAY_OF_MONTH);
gc.add(Calendar.DAY_OF_MONTH, 100); //현재 날짜에 100일 더함
String _100day = ""+gc.get(Calendar.YEAR)+"-"+(gc.get(Calendar.MONTH)+1)+"-"+gc.get(Calendar.DAY_OF_MONTH);
Toast.makeText(this, today+"\n"+_100day, Toast.LENGTH_LONG).show();