According to Javadocs:
public Date (int year, int month, int day)
This constructor was deprecated in API level 1.
Date date = new Date(year,month,date);
This constructor is deprecated in API Level 1, but my Eclipse does not give me an obsolescence warning in the Android project that I am creating. What could be the problem? Is there a stupid mistake I am making?
- I compiled the project in version
4.0. - I checked the Lint settings and this is great.
- I did not install
@SuppressWarnings, so this is out of the question.
This is the code I'm using:
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import android.app.Activity;
import android.app.DatePickerDialog;
import android.app.DatePickerDialog.OnDateSetListener;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Paint;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;
@Override
protected Dialog onCreateDialog(int id) {
Calendar mCalen = Calendar.getInstance();
int day = mCalen.get(Calendar.DAY_OF_MONTH);
int month = mCalen.get(Calendar.MONTH);
int year = mCalen.get(Calendar.YEAR);
return new DatePickerDialog(this, new OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
String newDate = new StringBuilder().append(dayOfMonth)
.append("/").append(monthOfYear + 1).append("/")
.append(year).toString();
date = null;
timeStamp = null;
dateStamp = 0;
date = newDate;
timeStamp = new Date(year, monthOfYear, dayOfMonth);
dateStamp = timeStamp.getTime();
dateTextView.setText(date);
}
}, year, month, day);
}

source
share