feature that adds date and time to the results file created

This commit is contained in:
Marcin Hutek 2023-12-09 23:46:48 +01:00
parent 5a7cf62d18
commit 73725c68e0
5 changed files with 60 additions and 21 deletions

View File

@ -0,0 +1,38 @@
%PDF-1.4
%âãÏÓ
2 0 obj
<</Length 155/Filter/FlateDecode>>stream
xœmν
Â0…á=Wñ-BI”6vtqQÈVbiÔ61?ïÞtSÈ™ÞáÎí9ÚTÀp\" %as¬<73>~GE§Ã§<C383>I8/¦%$ƒÿh!•ïœ¶A±<E280BA>3O5B÷2Qú,j°Ê‰<10>jO×hMWl¥Ö)ïgןEã:ëú8h™n¶¤v$kÊÌ~à<>£ úÚ-DÏ
endstream
endobj
4 0 obj
<</Type/Page/MediaBox[0 0 595 842]/Resources<</Font<</F1 1 0 R>>>>/Contents 2 0 R/Parent 3 0 R>>
endobj
1 0 obj
<</Type/Font/Subtype/Type1/BaseFont/Helvetica/Encoding/WinAnsiEncoding>>
endobj
3 0 obj
<</Type/Pages/Count 1/Kids[4 0 R]>>
endobj
5 0 obj
<</Type/Catalog/Pages 3 0 R>>
endobj
6 0 obj
<</Producer(iText® 5.5.13 ©2000-2018 iText Group NV \(AGPL-version\))/CreationDate(D:20231209234439+01'00')/ModDate(D:20231209234439+01'00')>>
endobj
xref
0 7
0000000000 65535 f
0000000349 00000 n
0000000015 00000 n
0000000437 00000 n
0000000237 00000 n
0000000488 00000 n
0000000533 00000 n
trailer
<</Size 7/Root 5 0 R/Info 6 0 R/ID [<1a7833db80448a42cbb4cd49ff42f716><1a7833db80448a42cbb4cd49ff42f716>]>>
%iText-5.5.13
startxref
691
%%EOF

View File

@ -0,0 +1 @@
[{"cityName":"warsaw","description":"broken clouds","temperature":273.31,"pressure":1007,"humidity":89}]

View File

@ -0,0 +1 @@
<ArrayList><item><cityName>chicago</cityName><description>clear sky</description><temperature>279.1</temperature><pressure>1012</pressure><humidity>62</humidity></item></ArrayList>

View File

@ -12,6 +12,9 @@ import model.*;
import java.io.IOException;
import java.util.*;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
//import java.io.File;
//import java.io.IOException;
//import java.sql.SQLOutput;
@ -38,6 +41,8 @@ public class Main {
CityNames cityNames = new CityNames();
cityNames.cityNamesRead(fileCities);
LocalDateTime czas = LocalDateTime.now();
Scanner scanner = new Scanner(System.in);
TemporaryFile temporaryFile = new TemporaryFile();
@ -83,18 +88,24 @@ public class Main {
System.out.println("W jakim formacie chcesz zapisac wyniki?\n pdf/json/xml");
String whichFormat = scanner.nextLine().toLowerCase();
if (Objects.equals(whichFormat, "pdf")) {
String outputFile = "results.pdf";
// ConvertResultPdf convertResult = new ConvertResultPdf(temporaryFile.FILE_NAME,
// "results.pdf");
// convertResult.convertToPdf();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd_HHmmss");
String sformatowanyCzas = czas.format(formatter);
String outputFile = "results" + sformatowanyCzas + ".pdf" ;
// System.out.println(sformatowanyCzas);
// System.out.println(outputFile);
weatherForecast.convertToPdf(temporaryFile.FILE_NAME, outputFile);
} else if (Objects.equals(whichFormat, "json")) {
String outputFile = "results.json";
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd_HHmmss");
String sformatowanyCzas = czas.format(formatter);
String outputFile = "results" + sformatowanyCzas + ".json";
weatherForecast.saveToJson(outputFile);
} else if (Objects.equals(whichFormat, "xml")) {
String outputFile = "results.xml";
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd_HHmmss");
String sformatowanyCzas = czas.format(formatter);
String outputFile = "results" + sformatowanyCzas + ".xml";
weatherForecast.saveToXml(outputFile);
} else {
System.out.println("Wprowadz poprawna opcje.");

View File

@ -1,18 +1,6 @@
city: chicago
description: light rain
temperature[K]: 285,44
pressure[hPa]: 1001
humidity[%]: 92
--------------------
city: chicago
description: light rain
temperature[K]: 285,44
pressure[hPa]: 1001
humidity[%]: 92
--------------------
city: chicago
description: light rain
temperature[K]: 285,44
pressure[hPa]: 1001
humidity[%]: 92
description: clear sky
temperature[K]: 279,10
pressure[hPa]: 1012
humidity[%]: 62
--------------------