0

I have these time formats in Java which I use to format the date:

dd-mm-yyyy
dd-mm-rr
dd-mon-yyyy
dd-mon-rr
dd/mon/yyyy 

When I use these time formats with JQuery time picker I get this output:

24-08-rr
24-08-20122012

Can you tell me how I can use one time format for Java and for JavaScript? How I can solve this problem?

5
  • 7
    Java is not Javascript. Except for the similar names, they're not related, and date formats in one are not going to be same as date formats in the other. You will have to adjust your format strings as necessary for each language. Commented Aug 15, 2012 at 16:49
  • This post describes how to format dates in Javascript. Commented Aug 15, 2012 at 16:51
  • What is "rr" in your format string? Commented Aug 15, 2012 at 16:56
  • JQuery time picker ? you mean jqueryui.com/demos/datepicker ? or any other plugin ? Commented Aug 15, 2012 at 17:01
  • If you can use momentjs on the client side, then you can use the momentjs/SimpleDateFormat converter to translate your SimpleDateFormat strings into momentjs format. Commented Dec 24, 2014 at 20:12

2 Answers 2

2

For example you can use next:
-On client side

$("#input-field-id").datepicker().mask("99/99/9999");  

-On server side

org.joda.time.format.DateTimeFormatter DATE_TIME_FORMATTER =
      DateTimeFormat.forPattern("MM/dd/yyyy");  
DATE_TIME_FORMATTER.parseDateTime(dateThatYouGatFromClientPart);
Sign up to request clarification or add additional context in comments.

Comments

2

You can use latest version of jQuery UI datepicker which has the following useful functions

Comments

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.