File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "RE: Calendar Class" Watch "RE: Calendar Class" New topic

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?

Ranch Hand

Joined: Sep 12, 2000
Posts: 63
Could you produce the code whereby you got the output?
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();
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());
I agree. Here's the link:
subject: RE: Calendar Class
It's not a secret anymore!