0

Showing a cross on Date

I am working in an Application to change and show the date but got a problem and the app crashes when the button is clicked. Here is the dialog from Android Studio Gradle Console:

MainActivity.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

How may I solve it and what is the reason?

VincenzoC
  • 30,117
  • 12
  • 90
  • 112
SHIBLI
  • 11
  • 1
  • Check this StackOverflow question for details on Date deprecation: http://stackoverflow.com/questions/5677470/java-why-is-the-date-constructor-deprecated-and-what-do-i-use-instead. However, the deprecation is unrelated to your app crash problem. – pczeus Feb 17 '17 at 02:33
  • Possible duplicate of [Java: Why is the Date constructor deprecated, and what do I use instead?](http://stackoverflow.com/questions/5677470/java-why-is-the-date-constructor-deprecated-and-what-do-i-use-instead) – Basil Bourque Feb 17 '17 at 02:53

1 Answers1

0

The Date class is deprecated.

Use Calendar instead: https://developer.android.com/reference/java/util/Calendar.html

theblitz
  • 6,683
  • 16
  • 60
  • 114
  • 1
    Incorrect. Most of the methods in [`java.util.Date`](http://docs.oracle.com/javase/8/docs/api/java/util/Date.html) are deprecated, but not the entire class. Practically speaking, Both `Date` and `Calendar` are supplanted by the java.time classes. – Basil Bourque Feb 17 '17 at 02:52
  • So finally I used this class and get rid of that problem. GregorianCalendar(year, month, day).getTime(); Thanks for the help – SHIBLI Feb 18 '17 at 10:25