0

I'm using java studio creator to build my application. I used the ajax component, Popup Calendar, and when I want to get the date and compare it with another date , I cann't :(. This is my code :

// My Code

  SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");

  java.util.Calendar startDate = java.util.Calendar.getInstance(); 
  startDate.setTime(dateFormat.parse(startField.getValue().toString()));   
//

Where startField is the calendar..

I tried to set the dateformattedpattern in the properties of the calendar to be the same as dataformat but it gave an exception.

Is there any suggestions to fix the problem?

4
  • 3
    What's the exception? What's the value of startField.getValue().toString()? ... ? Commented Jun 16, 2011 at 10:47
  • the exception is unparseable date. Commented Jun 16, 2011 at 21:42
  • And what's the value of startField.getValue().toString()? Commented Jun 17, 2011 at 4:32
  • See Jigar Joshi's answer then, try changing new SimpleDateFormat("yyyy/MM/dd") to new SimpleDateFormat("yyyy-MM-dd") Commented Jun 17, 2011 at 9:06

1 Answer 1

2

startField.getValue().toString() should be of the form yyyy/MM/dd

Sign up to request clarification or add additional context in comments.

2 Comments

Try to print what does startField.getValue().toString() return.
I printed the date that is given from the calendar, it is 2011-06-16.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.