Can't Check For Invalid Date

Why does the following code not detect that the date (i.e. the month) is invalid?
import java.text.SimpleDateFormat;
import java.text.ParseException;
import java.util.Date;
public class dateCompare
     public static void main(String[] args)
          String startDateString = "15/22/2002";
          try
               SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
               sdf.parse(startDateString);
          catch (ParseException e)
               e.printStackTrace();
}

I modified your code like this:
Date date = sdf.parse(startDateString);
System.out.println(date);And this is the output it produced:
Sat Mar 22 00:00:00 PST 2003
So, it looks like it's taking the 15, assuming you mean 12 + 3 months, and applying that to the year --- thus, it becomes March 2003.

Similar Messages

  • Can I exit from paintComponent?  ...or... how can I check for invalid data?

    I'm writing a calendar applet for a programming class and I've nearly completed it but I'm stuck at checking for valid data.
    What seems to be happening is that paintComponent() is being called before actionPerformed.
    In actionPerformed (when they click the button), it checks to make sure they entered a valid month (1 to 12). If the didn't it dispalys a message, but if they did it calls repaint().
    But even if repaint() isn't called, Java still seems to call it before actionPerformed and I get exceptions.
    So I tried checking inside of paintComponent() by using a simple if(...) return; but that doesn't seem to do anything... it just keeps going through with the method.
    So -- Once the user presses my button I want to make sure the data is valid before repainting the screen. How can I do this?

    I validate it in actionPerformed which is called by
    the action listener... that is what you meant right?
    The problem is that it seems paintComponent() is being
    called before I can validate the data with
    actionPerformed(). I need to stop paintComponent()
    from always being calledMVC. (Model, View, Controller)
    Initially the internal value of the data (the model) should be valid (or null with a check in the paintComponent method)
    paintComponent (the view part) shows the state of the valid data.
    You press the button.
    actionPerformed is called (the controller).
    It checks the value and, if valid, writes it to the data (model), then updates the view.
    At no point will the view have to render invalid data, because the model is only updated after actionPerformed checks the value.
    The pattern may be applied with different classes performing the three roles, or different methods in the same class (sometimes it's easier that way for simple cases).
    Pete

  • Can i check for invalid chars inside characters () method

    Hi There
    Cani check for invalid charcaters inside characters() method of SAX api so as to take care of invalid charactrers that mey come up while parsing an xml file from the internet
    Thanks
    Mum

    Hi DrClap
    Thanks for responding.But i have no control on the encoding of the xml file that is coming to me
    So i will be thankful to u if u could just tell me if there is any way in which i can change the encoding format used for parsing the xml file so my parsing process reaches its logical end
    Thanks
    Mumtaz

  • I just buy iPhone4 first hand on Jan 07,2013 but the warranty expire date How can i check for the date of production?

    I was bought iPhone4 16 GB on Jan 07, 2013 from online shop from Laos they told me that this iPhone from Apple in Hongkong (first hand) but I check for the warranty is already expire date. What should we do? I want to know about my iPhone4 first hand or second hand. How can i check?

    This will show you warranty status and give you an idea
    of when originally sold:
    https://selfsolve.apple.com/agreementWarrantyDynamic.do

  • How can i check for corrupt data

    I have a lot of machine embroidery designs stored on my imac and have reason to believe some may have corrupt data which is not evident when opening but has caused major damage to memory board in sewing machine. Is there anyway to scan for corrupt files?

    My wifes sewing machine is in for service and repair because a couple of designs in the memory have somehow become too big for the machine to open them so it is not possible to edit or delete them. I sent the designs to brother and their machines developed a problem as well so they had to change the memory board and they can only put it down to a corrupt file even though they can't prove it as virus scans show all clear and the designs work fine on the computer with the sewing software program. Our machine worked fine except for not being able to remove 3 designs. Brother said their machines version number changed and also couldn't remove the designs. I have read that if a file is corrupt, backup software will detect it but again no problem there. I have sent the suspect designs to someone in the US who is going to access the design and see if they can find anything but at the moment I can't get any answers because its never happened before. Any ideas would be greatly appreciated.
    Regards
    Dennis

  • How can i check my purchase date for my apple 5s

    how can i check my purchase date for my apple 5s

    Plug the SN in here:
    https://getsupport.apple.com/ProductSelector.action
    iPhone warranty starts the day the phone is first sold.

  • How can i check the planned data vs actual data

    How can i check the planned data vs actual data with the infocubes?

    Hi Srinivas,
    You create one cube for plan data and create another cube for actual data.
    Create a multiprovider and give comparision report. this is betterway.
    Or you can also load actual and plan data in one cube but you need to maintain one character like version to seperate atual and plan data.This is not a good work.
    Regards,
    Vijay.

  • [svn:bz-trunk] 9838: Bug: BLZ-416  - Can bypass checks for which channel and protocol a destination can be called over by using NetConnection instead of BlazeDS messaging .

    Revision: 9838
    Author:   [email protected]
    Date:     2009-08-31 11:27:50 -0700 (Mon, 31 Aug 2009)
    Log Message:
    Bug: BLZ-416  - Can bypass checks for which channel and protocol a destination can be called over by using NetConnection instead of BlazeDS messaging.
    QA: Yes
    Doc: Yes - note the new enforce-endpoint-validation setting.
    Details: Added the following config setting:
    Ticket Links:
        http://bugs.adobe.com/jira/browse/BLZ-416
    Modified Paths:
        blazeds/trunk/modules/common/src/flex/messaging/config/ConfigurationConstants.java
        blazeds/trunk/modules/core/src/flex/messaging/MessageBroker.java
        blazeds/trunk/modules/core/src/flex/messaging/config/MessagingConfiguration.java
        blazeds/trunk/modules/core/src/flex/messaging/config/ServerConfigurationParser.java
        blazeds/trunk/modules/core/src/flex/messaging/config/SystemSettings.java

  • How can I check for VSearch trojan?

    how can I check for VSearch trojan? And then remove it if found?

    Helpful Links Regarding Malware Problems
    If you are having an immediate problem with ads popping up see The Safe Mac » Adware Removal Guide, AdwareMedic, or Remove unwanted adware that displays pop-up ads and graphics on your Mac - Apple Support.
    Open Safari, select Preferences from the Safari menu. Click on Extensions icon in the toolbar. Disable all Extensions. If this stops your problem, then re-enable them one by one until the problem returns. Now remove that extension as it is causing the problem.

  • How can I check for the existence of an XML file in Illustrator Javascript??

    I'm writing a Javascript to run at startup. I want to check for the existence of XML files and process them, if they are available. How can I check for their existence?

    Your first line just sets a variable to a string value… getFiles() is a method of Folder… so
    var InputXMLDir = Folder( "D:/Brackets/Create_Bracket_Graphics/Input/XML-n-Templates/" );
    Not a PC user so I can't remember if the colon is OK…? As you appear to know the file name why bother with a folder get files anyhow you could just check if the file exists then do some thing…
    alert( File( "D:/Brackets/Create_Bracket_Graphics/Input/XML-n-Templates/brackets_men_web.xml" ).exists );

  • How can I check the expiration date of a Certificate Keychain from terminal?

    Hello, I am writing a bash script to alert me when my corporate certificates are about to expire. How can I check the expiration date of a certificate in keychain? I'm running Mac OS 10.6.8 on a newer MacBook pro with full admin rights.
    Specifically I will be checking three certs: a Root Authority, Issuing Authority, and a user cert (Identity).
    I was exploring the Security and Openssl command line tools. But I can't seem to get the info I need.
    Any recommendations would be appreciated.
    Thank you!

    Anyone?

  • Hi, The computer in my MacBook Pro 10.6.8 isn't showing up in Skype (the indicator light doesn't show and it doesn't show in Skype preferences). Also Photo Booth doesn't recognize a camera. What can I check for please?

    Hi, The computer in my MacBook Pro 10.6.8 isn't showing up in Skype (the indicator light doesn't show and it doesn't show in Skype preferences). Also Photo Booth doesn't recognize a camera. What can I check for please?

    Hi Lee again..
    Please do not startup duplicate topics. I responded to you here >  Hi, The camera in my MacBook Pro 10.6.8...: Apple Support Communities
    Sometimes navigating the forums can be difficult.. we understand that.

  • I wan't update using itunes, i want to make update using my phone, but when check for an update using software update in setting message appear " can't check for update....."?

    i wan't update using itunes, i want to make update using my phone, but when check for an update using software update in setting message appear " can't check for update....."?

    Reboot the device and see if the error happens again. Updating through iTunes is usually optimal, but the file size differs via Software Update on the device and iTunes (50MB vs ~800MB)

  • Software Update can't check for updates because of a network problem....after firmware update

    I just bought a MBP w/Lion (10.7.4) and ran software update.  The first two items I updated were firmware for SMC (ver 1.5) and EFI (ver 2.7) and now my MBP says: "Software Update can't check for updates because of a network problem."  However, I can connect to the Internet to surf the web just fine.  This is the only update I've made.  Can firmware be uninstalled?  If I reverted to the image on my external drive that I did with CCC prior to the update, would that fix it?

    Hi! i hope i'm able to explain what i worked out and what worked for me. I had the same message coming up "no internet connection, run network/internet diagnosis" etc etc. Internet connection was fine. What i finally did:
    Open airport, check internet, internet options ; with me, IPv6 was set as  this (the letters are in german order and not in a english order, sorry...):
    In system prefs, network/TCP/IP  IPv6 was set to "automatic":
    I did change the settings in Airport back to "Link Local" and Software Update worked immediately normal whithout restarting the computer.
    No idea what changed the settings; however i did run permission repairs beforehand with no connection to any problems, just as a normal kind of 'maintenance routine'.
    Hope this helps others, it worked for me.
    Cheers
    Csico 

  • Software Update can't check for updates because of a network problem.

    The software update app fails with following error msgs. But all network functions fine.
    +A networking error has occurred: timed out (-1001). Make sure you can connect to the Internet, then try again.+
    +Software Update can't check for updates because of a network problem.+
    Deleted the software update plist files in $HOME/Library/Preferences, $HOME/Library/Preferences/ByHost, and HD/Library/Preferences, as per some posts. no effect. Problem persists.
    Any Ideas?
    Thanks

    Same here
    The last update I managed to do without problems was +Java for Mac OS X 10.5 Update 5+ - since yesterday the update process has become much, much slower and when I try to install +Security Update 2009 005+ and +iTunes 9+, it fails, usually with the aforementioned error, but also sometimes with Error 400 or Error 600, IIRC.

Maybe you are looking for

  • OATS - Browser is not getting launched when I click on the record button.

    Hi, I've just installed Oracle Application Testing Suite in my machine. During the installation process I was intimated that the EmpAppServer in the installation path does not contain the jboss binaries. However, it allowed me to continue with the in

  • Need help on how to a user can control a video clip using their mouse

    I need help. I've got a video clip of a rotating 3D object(left to right) and i would like the user to be able to control the rotation of the object using their mouse. I've looked everywhere and i'm at a lost. Can anyone help me Here is a link to wha

  • Web Report - ABAP Vs JAVA engine - ABAP 10 times faster than JAVA

    Guys, I want to share what we found in our project and see if any of you have insights into our findings.We are on NW2004S SP14 and we are moving to SP15 in a couple of weeks.We created query, developed WAD for it and executing the WAD takes for this

  • Trouble installing AIR 2.7 on Win7 64-bit

    Somehow air was uninstalled from my system.  I downloaded 2.7 and have been trying to install it and am getting the following error: "Sorry, an error has occurred.  An error occurred while installing Adobe AIR.  Installation may not be allowed by you

  • ADF UI to BPM Payload

    Experts I have a requirement where i parse attached file and have them displayed in table structure, the user would select the approvers for each row from a dropdown and then this whole information needs to be put in array payload to be used by Oracl