⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 utilaircraft.java

📁 java小程序
💻 JAVA
字号:
package org.aircraft.record;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.StringTokenizer;

public class UtilAircraft {

	public void aircraftInfo() {

		StringBuffer sb = new StringBuffer("");
		try {
			SimpleDateFormat simpledate = new SimpleDateFormat("yyyy-MM-dd");
			
			FileReader reader = new FileReader("E:/AMS/AircraftRecord/src/org/aircraft/record/aircraftlog.txt");
			BufferedReader brFile = new BufferedReader(reader);
			
			
			BufferedReader brUser = new BufferedReader(new InputStreamReader(System.in));
			
			System.out.println("Please input Date, Date formate must be: YYYY-MM-DD, Such as: 2008-01-02, Thanks.");
			String InputYYYYMMDD = brUser.readLine();
//			System.out.println("Your input Date is: " + InputYYYYMMDD);
			System.out.println("====================================================================================");
			Date InputDate = null;
			InputDate = simpledate.parse(InputYYYYMMDD);
			
			StringTokenizer strTokenizer;
			String lineInfo = null;
			StringBuffer outputInfo = new StringBuffer();
			outputInfo.append("Your input Date is: " + InputYYYYMMDD + "\n");
			outputInfo.append("               (Placed in service)    (maintenance)\n");
			outputInfo.append("AircraftID    |  year |  MM  |  DD  || year |  MM  |  DD  |elapsed days| Maintence(Yes/No)\n");

			while ((lineInfo = brFile.readLine()) != null) {

				strTokenizer = new StringTokenizer(lineInfo);
				String airCraft = strTokenizer.nextToken();
				
				while(strTokenizer.hasMoreTokens()) {
					String yyyyIntServ = strTokenizer.nextToken();
					String mmIntServ = strTokenizer.nextToken();
					String ddIntServ = strTokenizer.nextToken();
//					System.out.println("Your input Date is: " + InputYYYYMMDD);
//					System.out.println("AIRCRAFT ID: " + airCraft);
//					System.out.println("Original Date: " + yyyyIntServ + " " + mmIntServ + " " + ddIntServ);
					outputInfo.append(airCraft);
					outputInfo.append("   ");
					outputInfo.append(yyyyIntServ);
					outputInfo.append("    ");
					outputInfo.append(mmIntServ);
					outputInfo.append("     ");
					outputInfo.append(ddIntServ);
					outputInfo.append("  ");
					
					Date servDate = null;
					servDate = simpledate.parse(yyyyIntServ + "-" + mmIntServ + "-" + ddIntServ);
					long distence = InputDate.getTime() - servDate.getTime();
					int elapsedDays = (int) (distence / (1000 * 60 * 60 * 24));
//					System.out.println("The total number of days that have elapsed since the aircraft was last serviced: " + elapsedDays + " Days");
					
					Integer yyyyIntMaint = new Integer(strTokenizer.nextToken());
					Integer mmIntMaint = new Integer(strTokenizer.nextToken());
					Integer ddIntMaint = new Integer(strTokenizer.nextToken());
					outputInfo.append("|| ");
					outputInfo.append(yyyyIntMaint);
					outputInfo.append("     ");
					outputInfo.append(mmIntMaint);
					outputInfo.append("     ");
					outputInfo.append(ddIntMaint);
					outputInfo.append("    ");
					
					outputInfo.append(elapsedDays);
					outputInfo.append("               ");
					
					if(elapsedDays > 90) {
//						System.out.println("Does The aircraft need maintence?: Yes");
						outputInfo.append("Yes");
						outputInfo.append("    ");
					} else {
						outputInfo.append("No");
						outputInfo.append("    ");
//						System.out.println("Does The aircraft need maintence?: No");
					}
					
//					System.out.println("Last Maintenced Date: " + yyyyIntMaint + " " + mmIntMaint + " " + ddIntMaint);
					
					outputInfo.append("\r\n");
					outputInfo.append("_________________________________________________________________________________________\r\n");
				}
//				System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
				sb.append(lineInfo + '\n');
			}
			
			System.out.println(outputInfo.toString());
			
			System.out.println("\r\n\r\n" + "Original Document are the followings:");
			System.out.println(sb);
			brFile.close();
			reader.close();
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		UtilAircraft utilAircraft = new UtilAircraft();
		utilAircraft.aircraftInfo();

	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -