Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

please help me ...

 
shashi booshan
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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....
 
Sunny Jaiswal
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should change the class name from "Date" to something else. Date class is already defined in java API.
 
Sumit Gaikaiwari
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
shashi booshan
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks
 
shashi booshan
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This code is ok.
 
Milan Sutaria
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
shashi booshan
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys.It worked
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic