number formatting

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rawringbuny
    New Member
    • Jan 2011
    • 2

    number formatting

    i have to display a transcript using JOptionPane or using the GUI text field.
    but i only know how to print it out using System.out.prin tf

    i have to print the yyyymmddnnn (where nnn is the serial no.)

    Code:
    int serialNo = 000;
    
          Calendar cal = Calendar.getInstance();
    
          date = cal.get(Calendar.DATE);
          month = cal.get(Calendar.MONTH) + 1;
          year = cal.get(Calendar.YEAR);
    
        System.out.printf("Testing =====> %d%d%d%03d\n",  year, month , date , serialNo);

    so how do i print the same format (yyyymmddnnn) using JOptionPane.sho wMessageDialog or GUI text field?


    plz help?
  • Dheeraj Joshi
    Recognized Expert Top Contributor
    • Jul 2009
    • 1129

    #2
    Use setText() method to set the text field.

    Code:
    strDate = year+month+date;
    setText(String strDate);
    Regards
    Dheeraj Joshi

    Comment

    Working...