Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RE: Calendar Class

 
mansoor iqbal
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mansoor,
Could you produce the code whereby you got the output?
Srikrish
 
mansoor iqbal
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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());
}
}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic