Forums Register Login

Time zones program

+Pie Number of slices to send: Send
Hi,

I need to create a program that that uses a superclass to get the time for 3 cities, using the Millisec method. Not sure how to get the tinme difference for each city:


import static java.lang.System.out;

import java.util.Calendar;
import java.util.Date;


public class WorldTime {


static int DAY_IM = 3 * 60 * 60 * 1000;

public static void main (String [] args){

WorldTime time [] = new WorldTime [3];

time[0] = new MunichTime();
time[1] = new NewYorkTime();
time[2] = new SydneyTime();

Calendar c = Calendar.getInstance();

c.set(2008, 2, 18);

long day1 = c.getTimeInMillis();

c.setTimeInMillis(day1);

out.println(String.format("Time:" , c));
}
}


public class MunichTime extends WorldTime {

}

public class NewYorkTime extends WorldTime {

}


public class SydneyTime extends WorldTime {

}
+Pie Number of slices to send: Send
Ok, I give you one something, This might help you,
no matter in which country I am, Following code will calculate current time in New York:



The main point to note down is First we need to calculate the GMT and I know the New York is GMT - 5.
Following URL will help you find out GMT of every place :
GMT difference
No more fooling around. Read this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 933 times.
Similar Threads
Devaka's Practice Exam1
Head First Java Exercise
Calendar Method
Headfirst Fullmoons exercise
Date
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 19:25:04.