Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. package com.nayana.exercicio1;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.FileReader;
  5. import java.io.IOException;
  6. import java.util.Date;
  7. import java.text.DateFormat;
  8. import java.text.ParseException;
  9. import java.text.SimpleDateFormat;
  10. import java.util.HashSet;
  11.  
  12.  
  13.  
  14. public class Main {
  15.  
  16. FileReader FileReader;
  17. BufferedReader BufferedReader;
  18. DateFormat format;
  19. HashSet<String> customer;
  20. HashSet<String> country;
  21. SimpleDateFormat formatter;
  22. Date date;
  23. ParseException ParseException;
  24. IOException IOException;
  25. int lines;
  26. String columns[];
  27. String line;
  28. String string;
  29. String formattedDate;
  30. Date datex;
  31. String readLine() {
  32. return null;
  33.  
  34. }
  35.  
  36.  
  37. }
  38.  
  39. package com.nayana.exercicio1;
  40.  
  41. import java.io.BufferedReader;
  42. import java.io.FileNotFoundException;
  43. import java.io.FileReader;
  44. import java.text.ParseException;
  45. import java.text.SimpleDateFormat;
  46. import java.util.Date;
  47. import java.util.HashSet;
  48.  
  49. public class Process {
  50.  
  51. public static void main(String[] args) throws FileNotFoundException, ParseException {
  52. Main pr = new Main();
  53.  
  54. pr.BufferedReader = new BufferedReader(new FileReader("C:\Users\nayan\Downloads\orders_04_20_07.txt"));
  55.  
  56.  
  57.  
  58. new String();
  59.  
  60. pr.lines = 0;
  61.  
  62. pr.customer = new HashSet<String>();
  63. pr.country = new HashSet<String>();
  64.  
  65.  
  66. System.out.println("Estas são as datas formatadas: " );
  67.  
  68.  
  69. while(pr.readLine() != null) {
  70.  
  71. pr.columns = ((String) pr.line).split(";");
  72. pr.lines++;
  73.  
  74. //CONTAR QUANTOS COSTUMERID DIFERENTES EXISTEM
  75.  
  76. pr.customer.add(pr.columns[4]);
  77. pr.customer.size();
  78.  
  79. //MOSTER DIFERENTES PAÍSES
  80.  
  81. pr.country.add(pr.columns[6]);
  82.  
  83. //CONVERTER DATA
  84.  
  85. pr.string = pr.columns[2];
  86. pr.format = new SimpleDateFormat("dd-MMM-yyyy");
  87. pr.date = (Date) pr.format.parse(pr.string);
  88. pr.format.format(pr.date);
  89. pr.formattedDate= "";
  90.  
  91.  
  92.  
  93. try {
  94.  
  95. pr.datex = (Date) pr.format.parse(pr.columns[2]);
  96. pr.formatter = new SimpleDateFormat("yyyy-dd-MM");
  97. pr.formattedDate = pr.formatter.format(pr.datex);
  98. } catch (ParseException e1) {
  99.  
  100. e1.printStackTrace();
  101. }
  102.  
  103. System.out.println(pr.formattedDate);
  104.  
  105.  
  106. }
  107. System.out.println("nO número total de linhas é: " + pr.lines);
  108. System.out.println("nO número total de CustomerId é: " + pr.customer.size());
  109. System.out.println("nDiferentes países existentes" + pr.country);
  110. }
  111.  
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement