Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: convert date format from 2017-09-21 to jtextbox

  1. #1
    Junior Member
    Join Date
    Sep 2017
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default convert date format from 2017-09-21 to jtextbox

    Hi,
    how to convert date value from 2017-09-21 to jtextbox?

    example date value is 2017-09-21 then it converted to 3 jtextbox whiches become
    jtextbox1 = 21
    jtextbox2 = 09
    jtextbox3 = 2017?

    Please help.....

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: convert date format from 2017-09-21 to jtextbox

    how to convert date value from 2017-09-21 to jtextbox?
    What is jtextbox? It is coded like it is a variable name. What data type is it?

    Is the value: 2017-09-21 in a String?

    The example implies that it is a String with numeric values separated with the "-" character.
    The String class's split() method is one way to extract the substrings separated by the "-" character.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Sep 2017
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: convert date format from 2017-09-21 to jtextbox

    Hi Norm,
    I did this but got error
            String Status;
            String TGL,part1,part2,part3;
                jCmbType.setSelectedIndex((int)jTable1.getModel().getValueAt(row, 0));
                jCmbTrxSource.setSelectedIndex((int)jTable1.getModel().getValueAt(row, 1));
                jtxtJournalNo.setText((String)jTable1.getModel().getValueAt(row, 2));
                TGL = (String)jTable1.getModel().getValueAt(row, 3).toString();
                String[] parts = TGL.split("-");
                part1 = parts[0];
                part2 = parts[1];
                part3 = parts[2];
                jCmbYear.setSelectedItem() = part1;

    the error messages is cannot applied to given types....

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: convert date format from 2017-09-21 to jtextbox

    the error messages is cannot applied to given types....
    Please copy the full text of the error messages and paste it here.

    The posted code does not show the data types for many of the variables used there.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Sep 2017
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: convert date format from 2017-09-21 to jtextbox

    Hi, the problem is solved just put the part1 inside jcmbyear
    jCmbYear.setSelectedItem() = part1; -----> jCmbYear.setSelectedItem(part1);

Similar Threads

  1. how to convert any date formats into yyyyMMdd format
    By anamika s in forum What's Wrong With My Code?
    Replies: 1
    Last Post: August 5th, 2014, 06:41 AM
  2. How to convert date to different format
    By sebE23 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: May 30th, 2013, 03:44 AM
  3. Java Date Format in Date Object
    By Ashr Raza in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 13th, 2012, 10:47 AM
  4. Working out the day from numeric date (dd/mm/yy format).
    By ShaunB in forum Java Theory & Questions
    Replies: 6
    Last Post: April 23rd, 2011, 08:55 PM
  5. date format
    By arunjib in forum Java Theory & Questions
    Replies: 4
    Last Post: March 12th, 2011, 01:42 PM