• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
Bartenders:
  • Carey Brown
  • salvin francis
  • Claude Moore

how to carry out the validation of input (LocalDate) from cmd  RSS feed

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys. I would like to carry out the validation of input from cmd in application responsbile for fetching rate data from national polish bank.
I need to input 3 arguments for example: EUR 2013-01-28 2013-01-31.

I need to validate two dates, 2 arguments with:
1) first date needs to be before next
2) input is in good pattern. I mean it cannot be 28-01-2013, it needs to be 2013-01-28.

Im using LocalDate.
For now, I am parsing String to LocalDate with LocalDate.parse, and it throws the DateTimeParseException when date is not correct, but I would like to log that exception and show message for example "You put date in wrong format". How can I do that? I have already interface called ConditionChecker that looks like this:



My main looks like this:


Currency validation is also in main, but it looks fine, no try/catch blocks etc and I want to achieve same thing with LocalDate.
Returning to localdates validation. It should be in CondtionChecker or how should I make it?

NbpParserEngine (if needed):



 
Rancher
Posts: 810
19
C++ Java MySQL Database Netbeans IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
must Janik,

you need to look at try/catch/finally  blocks:

put your operation for date conversion in the try and then you can do your reporting errors in the catch block, the finally can be unused.

Les
 
The government thinks you are too stupid to make your own lightbulb choices. But this tiny ad thinks you are smart:
Create Edit Print & Convert PDF Using Free API with Java
https://coderanch.com/wiki/703735/Create-Convert-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!