Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

getInstance Method of Calendar Class

  Asked By: Steven    Date: Apr 09    Category: Java    Views: 969
  

I want to know implementation of getInstance method of Calendar
class. Calendar class is abstract but how is it returning object of
calendar class? I am very confused with it. I will be waiting for
your reply.

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Leonard Pierce     Answered On: Apr 09

When you call Calendar.getInstance().. it will internally creates
java.uti.GregorianCalendar.. and returns the same. GregorianCalendar is subclass
of Calendar So... it can return GregorianCalendar object.

 
Answer #2    Answered By: Elisabeth Bell     Answered On: Apr 09

for example :
.
.
.
Calendar cld = Calendar.getInstance();
Timestamp geldegtar = rs.getTimestamp(new String(myDate));
if (geldegtar == null)
{
Calendar rightNow = Calendar.getInstance();
rightNow.set(1900, 0, 0);
java.util.Date mydate = rightNow.getTime();
long long_mydate = mydate.getTime();
geldegtar = new java.sql.Timestamp(long_mydate);
}
d = new Date(geldegtar.getTime() + (geldegtar.getNanos() /
1000000));
cld.setTime(d);
and then just use cld...
for axample;
int isaat = cld.get(Calendar.HOUR_OF_DAY);
int idak = cld.get(Calendar.MINUTE);
int isaniye = cld.get(Calendar.SECOND);

.
.

 
Didn't find what you were looking for? Find more on getInstance Method of Calendar Class Or get search suggestion and latest updates.




Tagged: