Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.nayana.exercicio1;
- import java.io.BufferedReader;
- import java.io.FileReader;
- import java.io.IOException;
- import java.util.Date;
- import java.text.DateFormat;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.HashSet;
- public class Main {
- FileReader FileReader;
- BufferedReader BufferedReader;
- DateFormat format;
- HashSet<String> customer;
- HashSet<String> country;
- SimpleDateFormat formatter;
- Date date;
- ParseException ParseException;
- IOException IOException;
- int lines;
- String columns[];
- String line;
- String string;
- String formattedDate;
- Date datex;
- String readLine() {
- return null;
- }
- }
- package com.nayana.exercicio1;
- import java.io.BufferedReader;
- import java.io.FileNotFoundException;
- import java.io.FileReader;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.Date;
- import java.util.HashSet;
- public class Process {
- public static void main(String[] args) throws FileNotFoundException, ParseException {
- Main pr = new Main();
- pr.BufferedReader = new BufferedReader(new FileReader("C:\Users\nayan\Downloads\orders_04_20_07.txt"));
- new String();
- pr.lines = 0;
- pr.customer = new HashSet<String>();
- pr.country = new HashSet<String>();
- System.out.println("Estas são as datas formatadas: " );
- while(pr.readLine() != null) {
- pr.columns = ((String) pr.line).split(";");
- pr.lines++;
- //CONTAR QUANTOS COSTUMERID DIFERENTES EXISTEM
- pr.customer.add(pr.columns[4]);
- pr.customer.size();
- //MOSTER DIFERENTES PAÍSES
- pr.country.add(pr.columns[6]);
- //CONVERTER DATA
- pr.string = pr.columns[2];
- pr.format = new SimpleDateFormat("dd-MMM-yyyy");
- pr.date = (Date) pr.format.parse(pr.string);
- pr.format.format(pr.date);
- pr.formattedDate= "";
- try {
- pr.datex = (Date) pr.format.parse(pr.columns[2]);
- pr.formatter = new SimpleDateFormat("yyyy-dd-MM");
- pr.formattedDate = pr.formatter.format(pr.datex);
- } catch (ParseException e1) {
- e1.printStackTrace();
- }
- System.out.println(pr.formattedDate);
- }
- System.out.println("nO número total de linhas é: " + pr.lines);
- System.out.println("nO número total de CustomerId é: " + pr.customer.size());
- System.out.println("nDiferentes países existentes" + pr.country);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement