库存中货物超期的天数

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;
 }
 
 
 
 

}
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值