时间的加减

转:http://david20080309.iteye.com/blog/459451

package com.zwj.struts.action;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;

import java.sql.Timestamp;

import com.lowagie.text.pdf.codec.postscript.ParseException;

/**
 * 专用小测试
 */
public class Mytest {

 private static Calendar time;

 /**
  * @param args
  */
 /**
  * @param args
  */
 /**
  * @param args
  */
 public static void main(String[] args) {
  // TODO Auto-generated method stub

  try {
   Date todayDate = new Date();
   Date tomorrowDate = new Date();
   todayDate.getTime();
   SimpleDateFormat sdf = new SimpleDateFormat("", Locale.CHINESE);
   sdf.applyPattern("yyyy年MM月dd日_HH点mm分ss秒");

   String timeStr = sdf.format(todayDate);
   System.out.print("Today   time   is:" + timeStr + "\r\n");
   todayDate.setYear(todayDate.getYear() + 1);
   tomorrowDate = todayDate;
   timeStr = sdf.format(tomorrowDate);
   System.out.print("Tomorrow   time   is:" + timeStr);
  } catch (Exception e) {
   e.printStackTrace();

  }

 }
}

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