Mtri Noval Mtri Noval - 3 years ago 175
Java Question

Cannot resolve symbol 'DateTime' android studio

I'm getting this error "Cannot resolve 'Date()'" and i don't know why.

If someone could explain why i'm getting it, i would be grateful.

Thank you

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
lblDateAndTime = (TextView)
findViewById(R.id.lblDateAndTime);
Button btnDate = (Button) findViewById(R.id.btnDate);
btnDate.setOnClickListener(new
View.OnClickListener() {
public void onClick(View v) {
new DatePickerDialog(dateandtime.this, d,
myCalendar.get(Calendar.YEAR),
myCalendar.get(Calendar.MONTH),

myCalendar.get(Calendar.DAY_OF_MONTH)).show();
}
});
Button btnTime = (Button) findViewById(R.id.btnTime);
btnTime.setOnClickListener(new
View.OnClickListener() {
public void onClick(View v) { new
TimePickerDialog(dateandtime.this, t,
myCalendar.get(Calendar.HOUR_OF_DAY),
myCalendar.get(Calendar.MINUTE), true).show();
}
});
updateLabel();
}// onCreate
}

Answer Source

Did you try something like this?

import java.util.Date;
public class DateDemo {

   public static void main(String args[]) {
      // Instantiate a Date object
      Date date = new Date();

      // display time and date using toString()
      System.out.println(date.toString());
   }
}

Make sure you import java.util.Date.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download