Date

import java.sql.Date;
import java.text.SimpleDateFormat;
import java.util.Calendar;
public class Test5 {
public static void main(String[] args) {
Calendar cal = Calendar.getInstance();
Date date  = new Date(System.currentTimeMillis());
System.out.println(date);
cal.add(Calendar.HOUR, -24);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
System.out.println(sdf.format(cal.getTime()));
}
}

你可能感兴趣的:(java,sql)