Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 13 Online
OpenStudy (anonymous):

i need help on java plz

OpenStudy (anonymous):

regarding?

OpenStudy (anonymous):

OpenStudy (anonymous):

here we r

OpenStudy (cwrw238):

sorry don't know java

OpenStudy (anonymous):

okay who is know about java

OpenStudy (anonymous):

for date & time you can use: import java.util.Date; class DateDemo { public static void main(String args[]) { // Instantiate a Date object Date date = new Date(); // display time and date using toString() System.out.println(date.toString()); } } output: Mon May 04 09:51:52 CDT 2009

OpenStudy (anonymous):

Date Comparison: There are following three ways to compare two dates: 1.You can use getTime( ) to obtain the number of milliseconds that have elapsed since midnight, January 1, 1970, for both objects and then compare these two values. 2.You can use the methods before( ), after( ), and equals( ). Because the 12th of the month comes before the 18th, for example, new Date(99, 2, 12).before(new Date (99, 2, 18)) returns true. 3.You can use the compareTo( ) method, which is defined by the Comparable interface and implemented by Date.

OpenStudy (anonymous):

Date Formatting using SimpleDateFormat: import java.util.*; import java.text.*; class DateDemo { public static void main(String args[]) { Date dNow = new Date( ); SimpleDateFormat ft = new SimpleDateFormat ("E yyyy.MM.dd 'at' hh:mm:ss a zzz"); System.out.println("Current Date: " + ft.format(dNow)); } } output: Sun 2004.07.18 at 04:14:09 PM PDT

OpenStudy (anonymous):

@moha_10 for other info. you can visit the website http://www.tutorialspoint.com/java/java_date_time.htm its a really nice website it has always helped me it'll help you too... good luck :)

OpenStudy (anonymous):

You need to show how much work you have done. Just posting questions and expecting answers doesn't work...u need to learn...

OpenStudy (anonymous):

thx too much annas i appreciate this

OpenStudy (anonymous):

If you have written some code, show us ! ye may help you proceed further/correct the code...

OpenStudy (anonymous):

plz jeet.in don't getting our business

OpenStudy (anonymous):

moha i got code for the clock: import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.*; public class Clock extends Frame implements MouseMotionListener{ int xmou=200; //set the center of circle int ymou=200; //set the center of circle double theta=-0.1047; //theta for second's hand int x=xmou; //x position of Second's hand int y=ymou; //y position of second's hand int p,b; //perpendicular and base of Second's hand int h; //hypotenous(heigth) of clock's hand double the= -0.1047; //theta for creating outer circle double thetamin=-0.1047; //theta for minutes hand int xm=xmou; //x position of minute's hand int ym=ymou; //y position of minute's hand int pmin,bmin; //perpendicular and base of Minute's hand double thetah=-0.1047; //theta for hour hand int xh=xmou; //y position of hour's hand int yh=ymou; //y position of hour's hand int ph,bh; //perpendicular and base of hour's hand double thetan=-0.0; //theta for numbers of clock int xn=xmou; //x position of Clock numbers int yn=ymou; //y position of Clock numbers int pn,bn; //perpendicular and base of clock numbers int num=0; //for writing the numbers //constructor Clock(){ super(); setSize(500,500); setBackground(Color.PINK); setVisible(true); addMouseMotionListener(this); } //method of implemented mouse interface public void mouseMoved(MouseEvent me){ } public void mouseDragged(MouseEvent me){ xmou=me.getX(); //changing the clock position on mouse drag ymou=me.getY(); //changing the clock position on mouse drag } //method to paint clock public void paint(Graphics g){ //for writing numbers in clock and outer circle for(int p=0;p<60;p++){ int xocir=xmou; //x position of outer circle int yocir=ymou; //y position of outer circle int pocir,bocir; //perpendicular and base of outer circle pocir= (int) (Math.sin(the) * (h+23)); bocir= (int) (Math.cos(the) * (h+23)); xocir=xocir-pocir; yocir=yocir-bocir; the=the - 0.1047; g.setColor(Color.BLUE); g.drawLine(xocir+5,yocir+5,xocir,yocir); g.setColor(Color.BLACK); if(p%5==0 ){ num++; if(num>12){ num=1; } xn=xmou; yn=ymou; if(thetan<=-6.28318531 ){ thetan=0.0; } thetan=thetan-0.523598776 ; pn= (int) (Math.sin(thetan) * (h+10)); bn= (int) (Math.cos(thetan) * (h+10)); xn=xn-pn; yn=yn-bn; g.drawString(""+num,xn-3,yn+5); } } //for drawing Clock hands g.setColor(Color.BLACK); g.drawLine(xmou,ymou,xm,ym); //drawing minute's hand g.drawLine(xmou,ymou,xh,yh); //drawing hour's hand g.setColor(Color.RED); g.drawLine(xmou,ymou,x,y); //drawing second's hand } public void newpoint(){ Calendar now = Calendar.getInstance(); //creating a Calendar variable for getting current time //for second hand x=xmou; y=ymou; theta=-0.1047; theta=theta*now.get(Calendar.SECOND); p= (int) (Math.sin(theta) * h); b= (int) (Math.cos(theta) * h); x=x-p; y=y-b; //theta=theta - 0.1047; //for minutes hand xm=xmou; ym=ymou; thetamin=-0.1047; thetamin=thetamin*now.get(Calendar.MINUTE); pmin= (int) (Math.sin(thetamin) * (h-6)); bmin= (int) (Math.cos(thetamin) * (h-6)); xm=xm-pmin; ym=ym-bmin; //for hour's hand xh=xmou; yh=ymou; thetah=-0.1047; thetah=thetah*now.get(Calendar.HOUR)*5; if (now.get(Calendar.MINUTE)>=12 && now.get(Calendar.MINUTE)<24){ thetah=thetah-0.1047; } else if(now.get(Calendar.MINUTE)>=24 && now.get(Calendar.MINUTE)<36){ thetah=thetah-(2*0.1047); } else if(now.get(Calendar.MINUTE)>=36 && now.get(Calendar.MINUTE)<48){ thetah=thetah-(3*0.1047); } else if(now.get(Calendar.MINUTE)>=48 && now.get(Calendar.MINUTE)<60){ thetah=thetah-(4*0.1047); } ph= (int) (Math.sin(thetah) * (h-15)); bh= (int) (Math.cos(thetah) * (h-15)); xh=xh-ph; yh=yh-bh; } public static void main(String[] args) { Clock m=new Clock(); m.h=60; while(true){ m.newpoint(); m.repaint(); try{ Thread.sleep(6); }catch(Exception e){ } } } }

OpenStudy (anonymous):

the code is made using threads

OpenStudy (anonymous):

Jeet.in is reffering to http://openstudy.com/code-of-conduct, which stats Don’t post only answers - guide the asker to a solution. There is no guidance here as I can see.

OpenStudy (anonymous):

ok bro i do know that direct answers are not allowed but how i can guide her in project its difficult thing its not like mathematics. i m also sorry for doing this but its difficult for me to guide her in java project

OpenStudy (anonymous):

Annas I understand but I would of first ask her/him to show some work because clearly this is an assignment. You can tell it is an assignment because he/she posted the assignment. He/she has not done a little bit of code far as we can tell.

OpenStudy (anonymous):

Also he has this same post here http://openstudy.com/study#/updates/50031249e4b0848ddd670a2d He is cross posting.

OpenStudy (anonymous):

Also, he did not even answer my question if he wanted to use awt,which you are using or Swing or SWT

OpenStudy (anonymous):

moha is a girl... and i just gave the code which can help her... i havent answered the whole assignment.

OpenStudy (anonymous):

@moha_10 - You must interact with the people helping you in order to learn. Also, telling people to 'mind their own business' is NOT the way to interact on OpenStudy. Pick ONE question, and don't simply post your entire assignment - ask a question, get help, and show what parts you understand and what parts you don't. All clear? Thank you.

OpenStudy (anonymous):

@cshalvey look i'm so sorry but he first start look to this plz and there is respect to my queastion http://openstudy.com/study#/updates/50031249e4b0848ddd670a2d and he also say explain explain what !! this is a code i understand by read it

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!