且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

android怎么样从给定字符串减去字符串

更新时间:2023-02-23 08:17:42

 的String [] = SeperatedDateValue天[1] .split(/); //天[1] = 2013年9月11日/ * SeperatedDateValue [0] //年份
SeperatedDateValue [1] //月
SeperatedDateValue [0] //天* /
e01.setText(SeperatedDateValue [0]);

和按钮上点击

显示您的日期字符串,因为它是在吐司使用你的日子[]变量的值

I'm getting string in button. text I want to display only specific character only but when click show full value in toast how I will do that?

Button e01;
String[] days = new String[7];
e01.setText(days[1]);  // 2013/09/11
//i want to display only 11

@Override
public void onClick (View v){
    // TODO Auto-generated method stub
    switch (v.getId()) {
        case R.id.e01:
            value = e01.getText().toString();
            Toast.makeText(this, value, Toast.LENGTH_SHORT).show();
            //value=// 2013/09/11
            break;
    }
}

calendarGlobal = Calendar.getInstance();
DateFormat df = new SimpleDateFormat("yyyy/MM/dd");
calendarGlobal.add(Calendar.WEEK_OF_YEAR, +currentweekno);
calendarGlobal.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
String[] days = new String[7];
for (int i = 0; i < 7; i++) {
  // days.add(df.format(calendarGlobal.getTime()));
  Log.d("TAG",df.format(calendarGlobal.getTime()));
  days[i] = df.format(calendarGlobal.getTime());
  e01.setText(days[1]);
  // ..

String[] SeperatedDateValue= days[1].split("/");//days[1] = "2013/09/11"

/*SeperatedDateValue[0]//Year
SeperatedDateValue[1]//Month
SeperatedDateValue[0]//Day*/


e01.setText(SeperatedDateValue[0]);

And on Button Click

Display your date string as it is on the Toast by using your days[] variable values