日付変換の問題


 public class GetTime {

	public static void main(String[] args) {
		try {
			SimpleDateFormat formatter = new SimpleDateFormat(
					"yyyy-MM-dd HH:mm:ss");
			Date date = formatter.parse(getGreenWich());
			Calendar now = Calendar.getInstance();

			changeDate(getGreenWich());
			System.out.println(" :" + formatter.format(now.getTime())
					+ "    " + " :" + formatter.format(date));
		} catch (ParseException e) {
			e.printStackTrace();
		}
	}

	/**
	 *  
	 * 
	 * @return greenWich
	 */
	public static String getGreenWich() {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		long mTime = System.currentTimeMillis();
		//  。 。
		int offset = Calendar.getInstance().getTimeZone().getRawOffset();
		Calendar c = Calendar.getInstance();
		c.setTime(new Date(mTime - offset));
		String greenWich = sdf.format(c.getTime());
		return greenWich;
	}

	/**
	 *  
	 * 
	 * 
	 */
	public static void changeDate(String var) throws ParseException {

		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Date date = format.parse(var);
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);

		GregorianCalendar ca = new GregorianCalendar(
				TimeZone.getTimeZone("GMT 00:00"));
		ca.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH),
				calendar.get(Calendar.DAY_OF_MONTH), calendar.get(Calendar.HOUR),
				calendar.get(Calendar.MINUTE), calendar.get(Calendar.SECOND));
		format.setTimeZone(TimeZone.getDefault());
		String localDate = format.format(ca.getTime());

		System.out.println(" :" + var+"    "+ " :" + localDate);
	}
}