Local Date 구하기
package org.hadoop.dna;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.TimeZone;
public class GetDate {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Calendar cal = Calendar.getInstance();
// get 3 hours ago (if want, uncomment below line)
//cal.set(Calendar.HOUR, cal.get(Calendar.HOUR)-3);
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd-HH");
format.setTimeZone(TimeZone.getTimeZone("Asia/Seoul"));
String date = format.format(cal.getTime());
System.out.println(date);
}
}
결과
20120409-19