Trivial class to show use of Date and Calendar objects : Calendar Date « Development Class « Java

Java
1. 2D Graphics GUI
2. 3D
3. Advanced Graphics
4. Ant
5. Apache Common
6. Chart
7. Collections Data Structure
8. Database SQL JDBC
9. Design Pattern
10. Development Class
11. Email
12. Event
13. File Input Output
14. Game
15. Hibernate
16. J2EE
17. J2ME
18. JDK 6
19. JSP
20. JSTL
21. Language Basics
22. Network Protocol
23. PDF RTF
24. Regular Expressions
25. Security
26. Servlets
27. Spring
28. Swing Components
29. Swing JFC
30. SWT JFace Eclipse
31. Threads
32. Tiny Application
33. Velocity
34. Web Services SOA
35. XML
Microsoft Office Word 2007 Tutorial
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Java » Development Class » Calendar DateScreenshots 
Trivial class to show use of Date and Calendar objects
Trivial class to show use of Date and Calendar objects


import java.text.DateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;

/** Trivial class to show use of Date & Calendar objects */
public class DateUse {

  /** Typical main method ("main program") declaration */
  public static void main(String[] av) {

    Locale l1 = new Locale("en""US"), l2 = new Locale("es""ES");

    // Create a Date object for May 5, 1986
    Calendar c = Calendar.getInstance();
    c.set(19860405)// May 5, 1986
    Date d1 = c.getTime();

    // Create a Date object for today.
    Date d2 = new Date()// today

    DateFormat df_us = DateFormat.getDateTimeInstance(DateFormat.MEDIUM,
        DateFormat.MEDIUM, l1), df_sp = DateFormat.getDateTimeInstance(
        DateFormat.MEDIUM, DateFormat.MEDIUM, l2);
    System.out.println("Date d1 for US is " + df_us.format(d1));
    System.out.println("Date d1 for Spain is " + df_sp.format(d1));
    System.out.println("Date d2 is " + df_us.format(d2));
  }
}




           
       
Related examples in the same category
1. When does the UNIX date get into troubleWhen does the UNIX date get into trouble
2. Convert longs (time_t in UNIX terminology) to seconds
3. Show use of Calendar objectsShow use of Calendar objects
4. How quickly can you press return
5. Easter - compute the day on which Easter fallsEaster - compute the day on which Easter falls
6. Show use of Calendar get() method with various parameters
7. TimeComputation for processing sqrt and Input and Output operations.
8. Bean to display a month calendar in a JPanelBean to display a month calendar in a JPanel
9. Show some date uses 1
10. Show dates before 1970
11. Compare Dates
12. Compare File Dates
13. Show some calendar calculations
14. The best way to format a date/time is to use
15. Create SimpleDateFormats from a string read from a file
16. DateCalAdd -- compute the difference between two dates
17. Show some date uses
18. Calendar DemoCalendar Demo
19. DateDiff -- compute the difference between two dates
20. DateAdd -- compute the difference between two dates
21. Date Format Test Date Format Test
22. Swing: Date Time EditorSwing: Date Time Editor
23. Match DateMatch Date
ww___w.__j___a___v__a__2__s___.___co___m_ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.