worldTime.java

류명운

·

2014. 11. 27. 20:43

반응형

package worldtime;


import java.util.*;

import java.text.*;


public class worldTime{


public void worldTime() {

// TODO Auto-generated constructor stub

}

public worldTime(String contryName2){

TimeZone tz;

Date date = new Date();

DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss (z Z)");

//"Greenwich"

tz = TimeZone.getTimeZone(contryName2); df.setTimeZone(tz);

System.out.format("%s%n%s%n%n", tz.getDisplayName(), df.format(date));

}

public worldTime(int contryCodeNumber2) {

// TODO Auto-generated constructor stub

String contN=null;

TimeZone tz2;

Date date = new Date();

DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss (z Z)");

switch(contryCodeNumber2)

{

case 1:

contN = "Asia/Seoul";

break;

case 2:

contN = "Grennwich";

break;

case 3:

contN = "America/Los_Angeles";

break;

case 4:

contN = "America/New_York";

break;

case 5:

contN = "Pacific/Honolulu";

break;

case 6:

contN = "Asia/Shanghai";

break;

}

tz2 = TimeZone.getTimeZone(contN); df.setTimeZone(tz2);

System.out.format("%s%n%s%n%n", tz2.getDisplayName(), df.format(date));

}

}


 

반응형