• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

ClockDisplay

 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
On to a new assignment now...



I get an error saying I am missing a return statement. But it is there. So what is the error message REALLY trying to tell me?
 
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The error is because you are not returning anything when the condition in the if clause is true.

 
Lisa Beglaw
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ahhh...I see.

So if I wanted to add AM or PM to the end how would I go about doing that? I want to keep the clock calculation at military time (24hr) but I want the display to show in regular 12h time. So 23:15 will display as 11:15 PM.

Do I need to define a new field for AM or PM?

And would that then be my 'return' statement?
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I feel the class SimpleDateFormat should help you.
Else declare a variable, update it accordingly and return it.
[ July 26, 2005: Message edited by: Srinivasa Raghavan ]
 
Lisa Beglaw
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I went to that site but it didn't really help me.

Now I have...

and am still getting the missing return type error.
 
Lisa Beglaw
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let my clarify that 'didn't really help me� comment. The help may be there, but I am unsure of how to decipher it.

I really haven't found that site to be good use for beginners like myself.
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now you are missing return statement in "if" & "else" clause.
Return a value at the end of the method.


[ July 26, 2005: Message edited by: Srinivasa Raghavan ]
[ July 26, 2005: Message edited by: Srinivasa Raghavan ]
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Lisa Beglaw:
Let my clarify that 'didn't really help me� comment. The help may be there, but I am unsure of how to decipher it.

I really haven't found that site to be good use for beginners like myself.



Have a look at this site this has a few sample codes. Search for SimpleDateformat in the webpage.
SimpleDateFormat is a class that converts a date to a specified format like short time , long time etc etc ..

Check also this article , it explains about the class
[ July 26, 2005: Message edited by: Srinivasa Raghavan ]
 
Lisa Beglaw
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So simple yet so complicated. I keep forgetting that 'else' ISN'T a return statement.

If I have void in my method then I don't need a return, anything else MUST end in "return" + something to return. An hour...and day...whatever.

I don't know when I will get that thru my head!

Thanks for your direction. I will check that other site out as well.
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But you should also have this in mind, that it's not a good practice, to declare all variables globally ( as a member variable).
[ July 26, 2005: Message edited by: Srinivasa Raghavan ]
 
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You may get rid of the else:

[ July 26, 2005: Message edited by: Stefan Wagner ]
 
Lisa Beglaw
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Stefan. I like that way too. Anything that can shorten it up a bit.

 
Well THAT's new! Comfort me, reliable tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic