Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Time zones program

 
Rebecca Plumb
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 {

}
 
Deepak Chopra
Ranch Hand
Posts: 433
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic