使用 getters/setters 解析字符串数据库中的日期

Parsing Date in string Database using getters/setters

我正在尝试从列表视图适配器获取到 Gmt+7 的日期:

protected void onResume() {
    // TODO Auto-generated method stub
    super.onResume();

    _teamlist.clear();

    db = new DBHelper(getApplicationContext());
    db.getWritableDatabase();

    ArrayList<TeamModel> team_list = getTeams2();

    for (int i = 0; i < team_list.size(); i++) {


        String tdate = team_list.get(i).getTeamdate();


        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
        sdf.setTimeZone(TimeZone.getTimeZone("GMT+7"));
        Date datex = null;
        try {
            datex = sdf.parse(tdate);
        } catch (ParseException e) {
            e.printStackTrace();
        }


        TeamModel _TeamModel = new TeamModel();

        _TeamModel.setTeamdate(datex);  ///// here the probleme !!!!!


        _teamlist.add(_TeamModel);
    }

}

在这一行 '_TeamModel.setTeamdate(datex)' 中的错误:"setTeamdate java.lang.String in TeamModel cannot be applied to java.util.Date "

我的get/setclass团队模型:

public class TeamModel {

public String   teamdate="";
....

public String getTeamdate() {
    return teamdate;
}

public void setTeamdate(String teamdate) {
    this.teamdate = teamdate;
}
}

我试图将此 class 中的团队日期更改为字符串中的日期,但它弄乱了我的 DBHelper

感谢“mithrop”的帮助,这就是我解决问题的方法:

        String tname = team_list.get(i).getTeamname();
        String topponent = team_list.get(i).getTeamopponent();
        String tdate111 = team_list.get(i).getTeamdate();


        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        sdf.setTimeZone(TimeZone.getTimeZone("GMT+9"));
        Date datex = null;
        try {
            datex = sdf.parse(tdate111);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        String tdate = sdf.format(datex);

        System.out.println(tdate);


        TeamModel _TeamModel = new TeamModel();

        _TeamModel.setTeamname(tname);
        _TeamModel.setTeamopponent(topponent);
        _TeamModel.setTeamdate(tdate);

        _teamlist.add(_TeamModel);