Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Quick Question on a Numerology Report

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is a post from http://www.dreamincode.net/forums/topic/143081-numerology-report/ - I couldnt figure out how to quote it. Basically what i am trying to figure out is how to make required user input in the format, mm / dd / yyyy with spaces before and after the dashes.




Thanks!
 
Bartender
Posts: 612
7
Mac OS X Python
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok,

Do you really want the user to input MMb/bDDb/bYYYY (where b is blank or space)

OR

Do you simply want the report to output as above?


If you want to user to input spaces, why?

-steve
 
Rancher
Posts: 3742
16
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ti Ru wrote:Basically what i am trying to figure out is how to make required user input in the format, mm / dd / yyyy with spaces before and after the dashes.


That code assumes there will be no spaces around the slashes (not dashes).
So if you want the user to enter spaces then you need to change lines 32 - 44 of your code.
The length of the line will no longer be 10 and you will have to check for spaces either side of where you currently set the values of symbol and symbol2.

Having said all that, you would actually be better off looking at the SimpleDateFormat class which will do all of this for you.
 
Ti Ru
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Its a requirment for the class. How would i go about accounting for the spaces before and after the dashes? Would the below code work?

mm / dd / yyyy
012345678910111213


 
Marshal
Posts: 74084
332
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch and well done finding the code button. But your indentation is inconsistent and you have too many blank lines. We have some suggestions about indentation, etc. You will find more help if you look at the first and second links in this previous post.

I shall see if I can improve your indentation, as well as breaking the longer lines, so you can see the way to do it.
 
Campbell Ritchie
Marshal
Posts: 74084
332
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have tried to improve the indentation.
Why are all your methods static? You should create a field for date (or day month year) and use non‑static methods.
Don't call the Birthday method so often. Make the check method return a boolean for valid date, and you can then call the method once in a loop. The methods should be called birthday and check, by the way.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ti Ru wrote:Would the below code work?


Have you tested it ?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic