Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4984005

b32,Long formatred hebrew/Arabic dates not correctly displayed in JTextField

XMLWordPrintable



      Name: jbT81659 Date: 01/27/2004

      Locale: ar_SA, ar_EG, en_US, iw_IL
      Regression: NO
      Build: Tiger b32, Tested on Windows 98 2nd Ed, Windows 2000 and Redhat9
      The LONG Formatted date for Hebrew/Arabic should have the following format
      yyyy MONTH dd i.e 2004 "Hebrew Month Name" 26

      JLabels included in the test case shows this format correctly

      JTextField shows the following format
      dd yyyyMONTH i.e 26 2004"Hebrew Month Name"

      Note that the two formats are different and that JTextField shows the wrong format
      Note that there is No space between the year and the month name in JTextField

      Describtion

      . Compile and run the attached test case dateTest.java
      . Follow the instructions supplied with the test case to verify which date case fails
      . Compare the date displayed by the JLabel and JtextField for case
      . Note that for LONG date format JTextField fails to display the Hebrew date correctly
      . Note that for FULL date format JTextField fails to display the Hebrew date correctly


      ------------dateTest.java------------
      /* Copyright (c) Sun Microsystems 2004
      $Header: $
      */

      import java.applet.*;
      import javax.swing.*;
      import java.awt.*;
      import javax.swing.event.*;
      import javax.swing.text.*;
      import javax.swing.border.*;
      import java.awt.event.*;
      import java.text.*;
      import java.util.*;

      public class dateTest extends JApplet
      {
          public void init()
          {
              theTest test = new theTest();
              getContentPane().add(test);
          }
              public static void main(String[] argv)
              {
                  JFrame frame = new JFrame("\u0645\u062b\u0627\u0644");
                  frame.setContentPane(new theTest());
                  frame.pack();
                  frame.setVisible(true);
                  frame.addWindowListener( new WindowAdapter()
                  {
                     public void windowClosing( WindowEvent e)
                     {
                      System.exit(0);
                     }
                  });
              }
      }

      class theTest extends JPanel
      {
          JTextPane describtion;
          JPanel[] internalPanel= new JPanel[5];
          JPanel[] container= new JPanel[5];
          DateFormat currentDate0, currentDate1, currentDate2, currentDate3;
          JLabel[] localeLabel= new JLabel[5];
          JLabel[] dateLabel= new JLabel[5];
          JTextField[] f= new JTextField[5];
          TitledBorder[] border= new TitledBorder[5];
          String titles[] ={ "SHORT", "MEDIUM", "LONG", "FULL"};
          int i;
          public theTest()
          {
              Date date;
              JPanel main;

              Locale[] locales = { new Locale("iw","IL"),
                                   new Locale("ar","SA"),
                                   new Locale("ar","EG"),
                                   new Locale("en","US") };


              date = new Date();

              for (i = 0; i<locales.length;i++)
              {
                  internalPanel[i] = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
                  internalPanel[i].setPreferredSize(new Dimension(400,100));
                  container[i] = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
                  border[i] = new TitledBorder(titles[i]);
                  border[i].setTitleColor(Color.GREEN);
                  container[i].add(internalPanel[i]);
                  container[i].setBorder(border[i]);
              }

      //Testing Short date Format

              for (int k= 0; k<locales.length;k++)
              {
                  currentDate1 = DateFormat.getDateInstance(DateFormat.SHORT, locales[k]);
                  localeLabel[k]= new JLabel("Locale is: "+locales[k].toString());
                  f[k]= new JTextField(currentDate1.format(date));
                  localeLabel[k].setPreferredSize(new Dimension(120,20));
                  localeLabel[k].setForeground(Color.blue);
                  dateLabel[k] = new JLabel(currentDate1.format(date));
                  dateLabel[k].setPreferredSize(new Dimension(120,20));
                  dateLabel[k].setBorder(new EtchedBorder());
                  localeLabel[k].setPreferredSize(new Dimension(120,20));
                  f[k].setPreferredSize(new Dimension(120,20));
                  internalPanel[0].add(localeLabel[k], BorderLayout.WEST);
                  internalPanel[0].add(dateLabel[k], BorderLayout.CENTER);
                  internalPanel[0].add(f[k], BorderLayout.EAST);
                  internalPanel[0].setPreferredSize(new Dimension(400,100));
              }

      //Testing Medium date Format

              for (int k= 0; k<locales.length;k++)
              {
                  currentDate2 = DateFormat.getDateInstance(DateFormat.MEDIUM, locales[k]);
                  localeLabel[k]= new JLabel("Locale is: "+locales[k].toString());
                  f[k]= new JTextField(currentDate2.format(date));
                  localeLabel[k].setPreferredSize(new Dimension(120,20));
                  localeLabel[k].setForeground(Color.blue);
                  dateLabel[k] = new JLabel(currentDate2.format(date));
                  dateLabel[k].setPreferredSize(new Dimension(120,20));
                  dateLabel[k].setBorder(new EtchedBorder());
                  localeLabel[k].setPreferredSize(new Dimension(120,20));
                  f[k].setPreferredSize(new Dimension(120,20));
                  internalPanel[1].add(localeLabel[k], BorderLayout.WEST);
                  internalPanel[1].add(dateLabel[k], BorderLayout.CENTER);
                  internalPanel[1].add(f[k], BorderLayout.EAST);
                  internalPanel[1].setPreferredSize(new Dimension(400,100));
              }



      //Testing LONG Format

              for (int k= 0; k<locales.length;k++)
              {
                  currentDate0 = DateFormat.getDateInstance(DateFormat.LONG, locales[k]);
                  localeLabel[k]= new JLabel("Locale is: "+locales[k].toString());
                  f[k]= new JTextField(currentDate0.format(date));
                  localeLabel[k].setPreferredSize(new Dimension(120,20));
                  localeLabel[k].setForeground(Color.blue);
                  dateLabel[k] = new JLabel(currentDate0.format(date));
                  dateLabel[k].setPreferredSize(new Dimension(120,20));
                  dateLabel[k].setBorder(new EtchedBorder());
                  localeLabel[k].setPreferredSize(new Dimension(120,20));
                  f[k].setPreferredSize(new Dimension(120,20));
                  internalPanel[2].add(localeLabel[k], BorderLayout.WEST);
                  internalPanel[2].add(dateLabel[k], BorderLayout.CENTER);
                  internalPanel[2].add(f[k], BorderLayout.EAST);
                  internalPanel[2].setPreferredSize(new Dimension(400,100));
              }

      //Testing FULL Format

              for (int k= 0; k<locales.length;k++)
              {
                  currentDate3 = DateFormat.getDateInstance(DateFormat.FULL, locales[k]);
                  localeLabel[k]= new JLabel("Locale is: "+locales[k].toString());
                  f[k]= new JTextField(currentDate3.format(date));
                  localeLabel[k].setPreferredSize(new Dimension(120,20));
                  localeLabel[k].setForeground(Color.blue);
                  dateLabel[k] = new JLabel(currentDate3.format(date));
                  dateLabel[k].setPreferredSize(new Dimension(160,20));
                  dateLabel[k].setBorder(new EtchedBorder());
                  localeLabel[k].setPreferredSize(new Dimension(120,20));
                  f[k].setPreferredSize(new Dimension(160,20));
                  internalPanel[3].add(localeLabel[k], BorderLayout.WEST);
                  internalPanel[3].add(dateLabel[k], BorderLayout.CENTER);
                  internalPanel[3].add(f[k], BorderLayout.EAST);
                  internalPanel[3].setPreferredSize(new Dimension(450,125));
              }
              
              //JPanel myPanel = new JPanel();
              JPanel myPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
              myPanel.setPreferredSize(new Dimension(700,700));
              for (i = 0; i<titles.length;i++)
              {
                myPanel.add(container[i]);
              }

              JTextPane describtion = new JTextPane();
              describtion.setEditable(false);
              describtion.setBackground(Color.lightGray);
              describtion.setContentType("text/html");
              describtion.setPreferredSize(new Dimension(700,120));
              describtion.setText("<html><body> <br>1. Verify the following for JLabel: <ul> <li>SHORT DATE Format is displayed totaly numeric dd/mm/yy for the Locale iw_IL </il> <li>SHORT DATE Format is displayed totaly numeric dd/mm/yy for the Locale ar_SA </il> <li>SHORT DATE Format is displayed totaly numeric dd/mm/yy for the Locale ar_SA </il> <li>SHORT DATE Format is displayed totaly numeric mm/dd/yy for the Locale en_US </li><li>If the Date is not displayed as explained, the test case fails</li><br> <li>MEDIUM DATE Format is displayed numeric dd/mm/yyyy for the Locale iw_IL </il> <li>MEDIUM DATE Format is displayed numeric dd/mm/yyyy for the Locale ar_SA</li> <li>MEDIUM DATE Format is displayed numeric dd/mm/yyyy for the Locale ar_EG</li> <li>MEDIUM DATE Format is displayed as follows \"Jan 15, 1971\" for the Locale en_US </il><br> <li>If the Date is not displayed as explained, the test case fails</li><br> <li>LONG DATE Format is displayed with full month name \"Year Month !
       dd\" for the Locale il_iw </il> <li>LONG DATE Format is displayed with full month name \"Year ,Month dd\" for the Locale ar_SA </il> <li>LONG DATE Format is displayed with full month name \"Year ,Month dd\" for the Locale ar_EG </il> <li>LONG DATE Format is displayed with full month name \"Month dd, year\" for the Locale En_US </il><li>If the Date is not displayed as explained, the test case fails</li><br> <li>FULL DATE Format is displayed with full day name, date and month name \"Year Month dd dd \u05d9\u05d5\u05dd for the Locale iw_IL </il><br> <li>FULL DATE Format is displayed with full month name \"Year ,Month dd\" for the Locale ar_SA </il> <li>FULL DATE Format is displayed with full month name \"Year ,Month dd\" for the Locale ar_EG </il> <li>FULL DATE Format is displayed with full Day and month names \"Day, Month dd, year\" for the Locale En_US </il><li>If the Date is not displayed as explained, the test case fails</li> </ul> <br>2. Verify the following for JTextFiel!
       d: <br> <ul> <li>SHORT DATE Format is displayed totaly numeric dd/mm/y
      y for the Locale iw_IL </il> <li>SHORT DATE Format is displayed totaly numeric dd/mm/yy for the Locale ar_SA </il> <li>SHORT DATE Format is displayed totaly numeric dd/mm/yy for the Locale ar_SA </il> <li>SHORT DATE Format is displayed totaly numeric mm/dd/yy for the Locale en_US </li><li>If the Date is not displayed as explained, the test case fails</li><br> <li>MEDIUM DATE Format is displayed numeric dd/mm/yyyy for the Locale iw_IL </il> <li>MEDIUM DATE Format is displayed numeric dd/mm/yyyy for the Locale ar_SA</li> <li>MEDIUM DATE Format is displayed numeric dd/mm/yyyy for the Locale ar_EG</li> <li>MEDIUM DATE Format is displayed as follows \"Jan 15, 1971\" for the Locale en_US </il><li>If the Date is not displayed as explained, the test case fails</li><br> <li>LONG DATE Format is displayed with full month name \"Year Month dd\" for the Locale il_iw </il> <li>LONG DATE Format is displayed with full month name \"Year ,Month dd\" for the Locale ar_SA </il> <li>LONG DATE Fo!
       rmat is displayed with full month name \"Year ,Month dd\" for the Locale ar_EG </il> <li>LONG DATE Format is displayed with full month name \"Month dd, year\" for the Locale En_US </il><li>If the Date is not displayed as explained, the test case fails</li><br> <li>FULL DATE Format is displayed with full day name, date and month name \"Year Month dd dd \u05d9\u05d5\u05dd\" for the Locale iw_IL </il> <li>FULL DATE Format is displayed with full month name \"Year ,Month dd\" for the Locale ar_SA </il> <li>FULL DATE Format is displayed with full month name \"Year ,Month dd\" for the Locale ar_EG </il> <li>FULL DATE Format is displayed with full Day and month names \"Day, Month dd, year\" for the Locale En_US </il><li>If the Date is not displayed as explained, the test case fails</li> </ul><br><br> </body></html>");
              JScrollPane scroll = new JScrollPane(describtion);
              scroll.setPreferredSize(new Dimension(699,150));
              myPanel.add(scroll);
              add(myPanel);
          }
      }

      -------------------------------------
      ======================================================================

            naoto Naoto Sato
            jbenavrasunw Jonathan Benavraham (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: