• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Recompile with -Xlint: deprecation for details...?

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This afternoon was busy doing a practical approach on the code below, after finished everything I tried to compile it, but the code could not compiled and got a message from the compiler saying:
Recompile with -Xlint: deprecation for details. Now I am stuck...please may you check this code out, need help. The code is suppose to create a digital clock...


 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

rodreck matava wrote:but the code could not compiled and got a message from the compiler saying:
Recompile with -Xlint: deprecation for details. Now I am stuck...



Well, what was the compiler error prior to the recompile recommendation? And when you recompiled with -Xlint, what was the messages?

Henry
 
rodreck matava
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Henry for your interest in my question...I am new to java programing I do not know how to recompile with Xlint? However did you look at the code? if yes, is there any obvious errors that you are detecting?...I will be glad to hear from you again...
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rodreck,
Here's how to compile with that flag: javac -Xlint:deprecation SimpleDigitalClock.java

Also, the code did compile and just gave you warnings. (There's a newer way of doing what you are trying to do. Hence the warnings.) Once you post the compiler warning, we are happy to suggest what you should do. Learning to do it is valuable so we are "making" you do it.
 
rodreck matava
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your response Jeanne, let me recompile right away...I will be writing to you regarding the results...by the way you said there is a newer way of writing this code?...
 
rodreck matava
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
After I recompile with javac -Xlint:deprecation SimpleDigitalClock.java I got three warnings...Jeanne,Thank you, now I need to solve the problem.
 
Jeanne Boyarsky
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rodreck,
It isn't a problem. Your code will run just fine with the older libraries. The code would be better with newer libraries.

Date has been deprecated for time manipulation for ages. If you are using Java 8, look at LocalDateTime. If not, look at GregorianCalendar.

ps - Henry and I were hinting you should post the output of the warnings. That way people helping you can start from there rather than have to start from the beginning.
 
rodreck matava
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay the list below is the warnings I got:

SimpleDigitalClock.java:72: warning : [deprecation] getHours() in Date has been deprecated
currentHour = myDate.getHours();
^
SimpleDigitalClock.java:73: warning : [deprecation] getMinutes() in Date has been deprecated
currentMinute = myDate.getMunites();
^
SimpleDigitalClock.java:74: warning : [deprecation] getSeconds() in Date has been deprecated
currentSecond = myDate.getSeconds();
^
3 warnings

 
Bartender
Posts: 2236
63
IntelliJ IDE Firefox Browser Spring Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Read the javadoc.
It says that this method has beed deprecated and tells you what you should use instead.

Also, you might want to consider using new java.time API.
 
Saloon Keeper
Posts: 15485
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As for compiler warnings in general, you can compile with -Xlint:all and get all warnings, including "serial", "rawtypes" and "unckecked", which pop up every now and then.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic