Discussion

How to Import Calendar class in Java Step

Hi, I a using Georgian calendar in a Java method in an activity. But the error I am getting is .... Test compilation failed: ---------- 1. ERROR in file://runtime:/PRGenJava/Rule_Obj_Activity_HNB_SS_Embed_Account_CalculateWaiveExpDate_20090310T152936_140_GMT.java (at line 504) Calendar calendar = new GregorianCalendar(); ^^^^^^^^ Calendar cannot be resolved to a type Can any body help me out how to import that package appropriatley. Thanks, Lenin.

***Updated by moderator: Marissa to close post***
This post has been archived for educational purposes. Contents and links will no longer be updated. If you have the same/similar question, please write a new post.

Comments

Keep up to date on this post and subscribe to comments

March 10, 2009 - 1:26pm

Use fully-qualified classnames:

java.util.Calendar calendar = new java.util.GregorianCalendar();

March 10, 2009 - 1:36pm

I tried that. It is not working........

March 10, 2009 - 1:38pm

re: It is not working........

If you supply the compile error, we might be able to better help you diagnose the problem.

Thanks,

Jon Garfunkel
Pega

March 10, 2009 - 1:40pm

Code in Progress
---------------------------------->>>

Calendar calendar = new GregorianCalendar();
Date trialTime = new Date();
calendar.setTime(trialTime);
calendar.set(0, 6, 0);
String year = Integer.toString(calendar.get(Calendar.YEAR));
String month = Integer.toString(calendar.get(Calendar.MONTH));
String day = Integer.toString(calendar.get(Calendar.DATE));
FinalExpDate = year.concat(month).concat(day);

And the error is:

Test compilation failed: ----------
1. ERROR in file://runtime:/PRGenJava/Rule_Obj_Activity_HNB_SS_Embed_Account_CalculateWaiveExpDate_20090310T152936_140_GMT.java
(at line 504)
Calendar calendar = new GregorianCalendar();
^^^^^^^^
Calendar cannot be resolved to a type
----------
2. ERROR in file://runtime:/PRGenJava/Rule_Obj_Activity_HNB_SS_Embed_Account_CalculateWaiveExpDate_20090310T152936_140_GMT.java
(at line 504)
Calendar calendar = new GregorianCalendar();
^^^^^^^^^^^^^^^^^
GregorianCalendar cannot be resolved to a type

March 10, 2009 - 1:43pm

And, once again: Use fully-qualified classnames

java.util.Calendar calendar = new java.util.GregorianCalendar();

"Fully-qualified" means to add the java.util prefix.
In common Java program, you might prefix your .java file with

import java.util.*;

If this is not present (which it isn't in PRPC Java-generation), than the compiler doesn't know where to search for the class. Fully-qualifying directs the compiler to look in the proper place.

Jon

March 10, 2009 - 6:16pm

Jon ,
Thanks. Its working.