Bonjourn, j'aimerai afficher la date du jour sous le format jj-mm-aa, mais ce que j'obtient c'est la fate sous le format 19 Juin 2010.
Voici le code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
 
public class temps extends JTextField implements Runnable{
 
 
    private DateFormat formatdate = DateFormat.getDateInstance();
  public void run() {
 
    try {
      while (true) {
 
         this.setText(formatdate.format(new Date()));
 
       Thread.sleep(1000);
 
      }
    }
    catch (Exception exception) {
      exception.printStackTrace();
    }
  }
//======================
 
//======================
  public temps() {
      this.setBackground(new Color(255, 254, 230));
      this.setForeground(Color.black);
      this.setFont(new java.awt.Font("Dialog", 1, 13));
      this.setSize(new Dimension(50, 30));
 
        Locale locale = Locale.getDefault();
 
            DateFormat formatdate = DateFormat.getDateInstance(DateFormat.SHORT,locale);
 
this.setText(formatdate.toString());
 
 
      this.setAlignmentX(JTextField.LEFT);
      this.setAlignmentY(JTextField.RIGHT);
 
      (new Thread(this)).start();
  }
}
Où peut être l'erreur d'après vous ?
Merci.