File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes please help me ... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "please help me ..." Watch "please help me ..." New topic
Author

please help me ...

shashi booshan
Greenhorn

Joined: Jun 13, 2008
Posts: 14
Hi guys i using jdk1.6 i m writing this program but this gives me a lot of error.. donno why....

here is the program. Its very simple... i sets the time and shows the new time

-----------------------------------------

import java.util.*;

class Date
{
public static void main(String[] args)
{
Date d1 = new Date(10000000000000L);
System.out.println("The date is " + d1.toString());
d1.setTime(d1.getTime() + 3600000);
System.out.println("New Date is " + d1.toString());
}
}

---------------------------------------
i dont know y i m gettin this ..
my system time has also been set correct.....
please help me....


Thanks & Regards
- Shashi
Sunny Jaiswal
Greenhorn

Joined: Feb 01, 2008
Posts: 14
You should change the class name from "Date" to something else. Date class is already defined in java API.


Preparing for SCJP...
Sumit Gaikaiwari
Greenhorn

Joined: Sep 24, 2007
Posts: 19
Or else replace first line of main method with following-

<blockquote>code:
<pre name="code" class="core"> java.util.Date d1 = new java.util.Date(10000000000000L); </pre>
</blockquote>

[ July 17, 2008: Message edited by: Sumit Gaikaiwari ]

~Sumit<br /><a href="http://faq.javaranch.com/view?ScjpWallOfFame" target="_blank" rel="nofollow">SCJP Wall of Fame</a>
shashi booshan
Greenhorn

Joined: Jun 13, 2008
Posts: 14
Thanks
shashi booshan
Greenhorn

Joined: Jun 13, 2008
Posts: 14
Again in this program im gettin the same problem...
this time i tried my best... bt dint worked out...
so many error coming saying incompatible types, cannot find symbol etc...
please help
<blockquote>code:
<pre name="code" class="core"> import java.util.*;

class Dates1
{
public static void main(String[] args) {
Date d1 = new Date(10000000000000L);
System.out.println("1st Date is:" + d1.toString());

Calendar c = Calendar.getInstance();
c.setTime(d1);

if(c.SUNDAY == c.getFirstDayOfWeek())
System.out.println("First day of the week is Sunday");
System.out.println("Trillionth milli day of the week is " + c.get(c.DAY_OF_WEEK));

c.add(Calendar.MONTH,1);

Date d2 = c.getTime();
System.out.println("new Date is " + d2.toString());
}
}
</pre>
</blockquote>
Raphael Rabadan
Ranch Hand

Joined: Jul 05, 2008
Posts: 141
This code is ok.


SCJP Java 6 (98%) - Story, SCJA (88%) - Story
Milan Sutaria
Ranch Hand

Joined: Jul 10, 2008
Posts: 122
if its runtime error ... try to delete the .class file & compile the .java file again. If its compile time error, post what is the error

for me its running perfectly fine. gives following output

1st Date is:Sat Nov 20 11:46:40 CST 2286
First day of the week is Sunday
Trillionth milli day of the week is 7
new Date is Mon Dec 20 11:46:40 CST 2286


SCJP 6 83%
Working on SCWCD/OCPJWCD
shashi booshan
Greenhorn

Joined: Jun 13, 2008
Posts: 14
Thanks guys.It worked
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: please help me ...