Show use of 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. Class
8. Collections Data Structure
9. Data Type
10. Database SQL JDBC
11. Design Pattern
12. Development Class
13. Email
14. Event
15. File Input Output
16. Game
17. Generics
18. Hibernate
19. I18N
20. J2EE
21. J2ME
22. JDK 6
23. JSP
24. JSTL
25. Language Basics
26. Network Protocol
27. PDF RTF
28. Reflection
29. Regular Expressions
30. Scripting
31. Security
32. Servlets
33. Spring
34. Swing Components
35. Swing JFC
36. SWT JFace Eclipse
37. Threads
38. Tiny Application
39. Velocity
40. Web Services SOA
41. XML
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
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java » Development Class » Calendar DateScreenshots 
Show use of Calendar objects
Show use of Calendar objects

import java.util.Calendar;
import java.util.GregorianCalendar;

/** Show use of Calendar objects */
public class GregCalDemo {

  public static void main(String[] av) {
    //+
    GregorianCalendar d1 = new GregorianCalendar(19860405)// May 5
    GregorianCalendar d2 = new GregorianCalendar()// today
    Calendar d3 = Calendar.getInstance()// today

    System.out.println("It was then " + d1.getTime());
    System.out.println("It is now " + d2.getTime());
    System.out.println("It is now " + d3.getTime());
    d3.set(Calendar.YEAR, 1915);
    d3.set(Calendar.MONTH, Calendar.APRIL);
    d3.set(Calendar.DAY_OF_MONTH, 12);
    System.out.println("D3 set to " + d3.getTime());
    //-
  }
}

           
       
Related examples in the same category
1. When does the UNIX date get into troubleWhen does the UNIX date get into trouble
2. Trivial class to show use of Date and Calendar objectsTrivial class to show use of Date and Calendar objects
3. Convert longs (time_t in UNIX terminology) to seconds
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
w__w_w.j_av___a2__s___.c___o_m___ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.