Asynctask Unknown ERROR

时间:2014-09-17 10:00:12

标签: android android-asynctask formatter

我使用Asynctask为Web服务开发了一个Android应用程序。 但是在任何时候标记线都有错误 找不到类:threadpoolexecutor,threadgroup.uncaughtexception,formatter

private class WebService extends AsyncTask<String, Void, String> {
    @Override
    protected String doInBackground(String... args) {
        String result = null;

        String title = args[0];
        String desc = args[1];

        String dt = getFullDate();
        String sql = "";// sql statement

        // Do something for upload to server

        return result;
    }

    private String getFullDate() {
        String cYear, cMonth, cDay, cHour, cMin, cSec;

        final Calendar cale = Calendar.getInstance();

        cYear = String.valueOf(cale.get(Calendar.YEAR));
        cMonth = fixZero(String.valueOf(cale.get(Calendar.MONTH) + 1), 2);
        cDay = fixZero(String.valueOf(cale.get(Calendar.DAY_OF_MONTH)), 2);

        cHour = fixZero(String.valueOf(cale.get(Calendar.HOUR_OF_DAY)), 2);
        cMin = fixZero(String.valueOf(cale.get(Calendar.MINUTE)), 2);
        cSec = fixZero(String.valueOf(cale.get(Calendar.SECOND)), 2);

        return cYear + "-" + cMonth + "-" + cDay + " " + cHour + ":" + cMin
                + ":" + cSec;
    }

    private String fixZero(String num, int len) {
        return String.format("%0" + len + "d", num); // <<< ERROR in that line 
    }
}

1 个答案:

答案 0 :(得分:0)

尝试此功能,希望对您有所帮助,

public String fixZero(String num, int len) {
    return String.format("%0"+len+"d", Integer.parseInt(num)); // <<< ERROR in that line 
}