/* Copyright (c) SEMM NL All rights reserved.
Author : Paul Hamaker. Part of JavaLessons.com
This code is for educational purposes only. Use at own risk.*/

1. import javax.swing.* ; 

2. import java.awt.* ; 

3. import java.awt.event.*; 

4. import java.util.Date

5. import java.text.* ; 

6.  

7. public class Dating 

8.     extends JApplet 

9.     implements ActionListener 

10.

11.   JTextArea ta ; 

12.   JButton bt ; 

13.  

14.   public void 

15.   actionPerformed ( ActionEvent ev ) 

16.   { 

17.     ta.setText( "" ); 

18.      

19.     DateFormat df ; 

20.  

21.     Date now = new Date ( ) ; 

22.  

23.     df = DateFormat.getDateTimeInstance (); 

24.  

25.     String tx = df.format ( now ) ; 

26.  

27.     ta.append ( "1.  " + tx  + "\n" ) ; 

28.     ta.append ( "********************************\n" ) ; 

29.  

30.     df = DateFormat.getDateTimeInstance 

31.       ( DateFormat.LONG, DateFormat.SHORT ); 

32.  

33.     tx = df.format ( now ) ; 

34.  

35.     ta.append ( "2.  " + tx  + "\n" ) ; 

36.     ta.append ( "********************************\n" ) ; 

37.  

38.     df = DateFormat.getDateInstance 

39.       ( DateFormat.FULL ); 

40.  

41.     tx = df.format ( now ) ; 

42.  

43.     ta.append ( "3.  " + tx  + "\n" ) ; 

44.     ta.append ( "********************************\n" ) ; 

45.  

46.     df = DateFormat.getDateInstance 

47.       ( DateFormat.MEDIUM ); 

48.  

49.     tx = df.format ( now ) ; 

50.  

51.     ta.append ( "4.  " + tx  + "\n" ) ; 

52.     ta.append ( "********************************\n" ) ; 

53.  

54.     SimpleDateFormat sdf = 

55.       new SimpleDateFormat ( "yyyy.MM.dd ' in week #'w" ) ; 

56.     tx = sdf.format ( now ) ; 

57.  

58.     ta.append ( "5.  " + tx  + "\n" ) ; 

59.     ta.append ( "==================================\n\n" ) ; 

60.   } 

61.   public void 

62.   init() 

63.   { 

64.     Container cp = getContentPane(); 

65.     ta= new JTextArea ( 15, 30 ) ; 

66.     cp.setLayout( new FlowLayout() ); 

67.     cp.add ( ta ) ; 

68.     bt = new JButton( "Show them" ); 

69.     cp.add( bt ); 

70.     cp.setBackground ( Color.orange ) ; 

71.     bt.addActionListener( this ) ; 

72.   } 

73.

74.