File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Time zones program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Time zones program" Watch "Time zones program" New topic
Author

Time zones program

Rebecca Plumb
Greenhorn

Joined: Dec 09, 2007
Posts: 9
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 {

}


Rebecca
Sunny Jain
Ranch Hand

Joined: Jul 23, 2007
Posts: 433

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


Thanks and Regards,
SCJP 1.5 (90%), SCWCD 1.5 (85%), The Jovial Java, java.util.concurrent tutorial
 
 
subject: Time zones program