aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes RE: Calendar Class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "RE: Calendar Class" Watch "RE: Calendar Class" New topic
Author

RE: Calendar Class

mansoor iqbal
Ranch Hand

Joined: Aug 14, 2000
Posts: 91
i am reproducing a code that i wrote. i was trying to practice the Calendar class by using some of its variables and methods. the PROBLEM is: the getInstance() method does not give me the current time. it gives me: java.util.Gregoriancalendar@0
how do i get the current time using the Calendar class?
how do i use the Date class to practice the Calendar class?
regards

------------------
srikrish
Ranch Hand

Joined: Sep 12, 2000
Posts: 63
Mansoor,
Could you produce the code whereby you got the output?
Srikrish
mansoor iqbal
Ranch Hand

Joined: Aug 14, 2000
Posts: 91
DUH!!!....the source code is given below
:
import java.util.*;
public class Cal
{
public static void main(String args[])
{
Date cL1=new Date();
Calendar cL=Calendar.getInstance();
//cL.computeTime();
System.out.println("Today is "+cL1);
System.out.println("Call from calendar "+cL);
System.out.println("first day of week "+cL.getFirstDayOfWeek());
System.out.println("day of week "+cL.DAY_OF_WEEK);
System.out.println("day of month "+cL.DAY_OF_MONTH);
System.out.println("date "+cL.DATE);
// System.out.println("date "+cL.getTimeInMillis());
}
}
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: RE: Calendar Class