Results 1 to 3 of 3
  1. #1
    Bibhukalyana is offline Member
    Join Date
    Apr 2013
    Posts
    4
    Rep Power
    0

    Default Get datetime from Jspinner

    Hi Everyone,
    I am trying to use JSpinner to pick date time.I set the date time format in yyyy-MM-dd HH.mm.ss format.
    Java Code:
    JSpinner oper_spinnerFrom = new JSpinner(new SpinnerDateModel());
    JSpinner.DateEditor de_oper_spinnerFrom = new JSpinner.DateEditor(oper_spinnerFrom, "yyyy-MM-dd HH.mm.ss");
    oper_spinnerFrom.setEditor(de_oper_spinnerFrom);
    Now i want to get value from JSpinner in same format.
    Java Code:
    System.out.println(oper_spinnerFrom.getValue().toString());
    But the output is Wed May 29 18:31:07 IST 2013.
    Can anybody tell me how to get in yyyy-MM-dd HH.mm.ss format ?

    Thanks.

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,690
    Rep Power
    8

    Default Re: Get datetime from Jspinner

    Use a DateFormat.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Bibhukalyana is offline Member
    Join Date
    Apr 2013
    Posts
    4
    Rep Power
    0

    Default Re: Get datetime from Jspinner

    Thanks. It is working.

    Java Code:
    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH.mm.ss");
    System.out.println(df.format(oper_spinnerFrom.getValue()));

Similar Threads

  1. Help with JSpinner
    By cyentw in forum New To Java
    Replies: 4
    Last Post: 02-11-2013, 05:40 AM
  2. Help me! how to use JSpinner
    By ngankt2 in forum AWT / Swing
    Replies: 1
    Last Post: 11-05-2010, 07:07 PM
  3. datetime??
    By pinar in forum New To Java
    Replies: 1
    Last Post: 10-26-2010, 11:17 PM
  4. JSpinner problem
    By damlui in forum AWT / Swing
    Replies: 0
    Last Post: 09-29-2010, 03:15 PM
  5. One Jspinner modifying the value of the other
    By cotarelo in forum AWT / Swing
    Replies: 1
    Last Post: 06-11-2010, 02:48 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •