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
posted
0
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
posted
0
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
posted
0
Thanks
shashi booshan
Greenhorn
Joined: Jun 13, 2008
Posts: 14
posted
0
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>
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
posted
0
Thanks guys.It worked
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.