库存中货物超期的天数

package stock;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import junit.framework.TestCase;

public class Test extends TestCase {
 
 private String monthfromdate;    //月初
 private String monthenddate;     //月末
 private long  periodday;  //周期
 private String indate;   //入库日期
 private String outdate;   //出库日期
 
 
 public Test(){}
 
 
 public Test(String monthfromdate, String monthenddate, long periodday, String indate, String outdate) {
  this.monthfromdate = monthfromdate;
  this.monthenddate = monthenddate;
  this.periodday = periodday;
  this.indate = indate;
  this.outdate = outdate;
 }

 public static long getCompareDate(String endDate,String startDate) throws ParseException{
      SimpleDateFormat formatter=new SimpleDateFormat("yyyy-MM-dd");
     

      Date date1=formatter.parse(startDate);
      Date date2=formatter.parse(endDate);
     
      long l = date2.getTime() - date1.getTime();
      long d = l/(24*60*60*1000);
      return d;
  }
 
 // 1。在库存中货物超期的天数
 // 2。月末后出库的货物超期的天数
 //monthfromdate,monthenddate,indate
 public long compulatoverday1() throws ParseException{
  
  long monthdays =  getCompareDate(monthenddate,monthfromdate);
  long infromdays = getCompareDate(monthfromdate,indate);
  long inenddays = getCompareDate(monthenddate,indate);
  
  if( monthdays <= periodday){
   
   Exception exception = new Exception("没有超期");
   
   return -1;
  }
  
  if(infromdays>=periodday)
  {
   return monthdays;
  }else{
   return inenddays-periodday;
  }
  
 }
 
 
 //1。本月中出货货物超期的天数
 public long compulatoverday2() throws ParseException{
  
  long stockdays =  getCompareDate(outdate,indate);
  long monthdays =  getCompareDate(monthenddate,monthfromdate);
  long infromdays = getCompareDate(monthfromdate,indate);
  long outfromdays =  getCompareDate(outdate,monthfromdate);
  //long outenddays =  getCompareDate(monthenddate,outdate);

  
  System.out.println("本月共" + monthdays + "天");
  if( stockdays <= periodday){
   
   Exception exception = new Exception("没有超期");
   
   return -1;
  }
  
  if(infromdays>=periodday)
  {
   return outfromdays;
  }else{
   return stockdays-periodday;
  }
  
 }
 
 
 
 
 public static void main(String[] args) throws ParseException {
  
  Test test = new Test("2007-06-01","2007-07-01",7,"2007-05-08","2007-6-28");
  System.out.print(test.compulatoverday2());
  
//  System.out.print(getCompareDate("2007-06-01","2007-06-01"));
  
 }
 
 
 
 

 public String getIndate() {
  return indate;
 }

 public void setIndate(String indate) {
  this.indate = indate;
 }

 public String getMonthenddate() {
  return monthenddate;
 }

 public void setMonthenddate(String monthenddate) {
  this.monthenddate = monthenddate;
 }

 public String getMonthfromdate() {
  return monthfromdate;
 }

 public void setMonthfromdate(String monthfromdate) {
  this.monthfromdate = monthfromdate;
 }

 public String getOutdate() {
  return outdate;
 }

 public void setOutdate(String outdate) {
  this.outdate = outdate;
 }

 public long getPeriodday() {
  return periodday;
 }

 public void setPeriodday(long periodday) {
  this.periodday = periodday;
 }
 
 
 
 

}
 

阅读更多
想对作者说点什么? 我来说一句

货物进销管理系统完整版.

2008年05月12日 12KB 下载

没有更多推荐了,返回首页

不良信息举报

库存中货物超期的天数

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭