Java 날짜 구문 분석 문자열 (분석 할 수없는 날짜)

Leandro Luccerini

이 두 부분의 코드가 있습니다.

arraylist에 추가하는 것은 작동하지 않으며 f arrylist는 항상 비어 있습니다. 출력 디버그 창에서받은 유일한 메시지는 Unparseable date : "2014-12-09 00 : 00 : 00.0"for each Fattura입니다.

private ArrayList<Fattura> getFatture() throws SQLException {

    String localDb;
    String unformattedQuery;

    ArrayList<Fattura> ftt = new ArrayList<Fattura>();

    if (this.serviceSelection.getSelectedItem() == "Energia") {
        localDb = EmailCheckerGUI.DbEnergia;
        unformattedQuery = ServiceQuery.RECUPERAFATTUREENERGIA.getQuery();

    } else {
        localDb = EmailCheckerGUI.DbGas;
        unformattedQuery = ServiceQuery.RECUPERAFATTUREGAS.getQuery();
    }

    DbHandlerContext db = new DbHandlerContext(new SqlServerConcrete(EmailCheckerGUI.user, EmailCheckerGUI.pwd, localDb));

    String formattedQuery = String.format(unformattedQuery,
            BillIntervalContainer.getFormattedMinDataFatt("MM/dd/yyyy"),
            BillIntervalContainer.getFormattedMaxDataFatt("MM/dd/yyyy"),
            BillIntervalContainer.minFattNumber, BillIntervalContainer.maxFattNumber);

    ResultSet r = db.executeQuery(formattedQuery);

    while (r.next()) {
        try {

            boolean addingelement = false;
            String ioError = "";

            try {

                addingelement = ftt.add(new Fattura(r.getInt("id"), r.getString("servizio"), r.getString("email"),
                        r.getString("denominazione"), r.getString("data_fattura"), r.getString("data_scadenza"), r.getString("path_fattura"),
                        r.getInt("inviato"), r.getString("report"), r.getInt("numero_fattura"), r.getInt("id_documento")));

            } catch (IOException ex) {
                Logger.getLogger(EmailCheckerGUI.class.getName()).log(Level.SEVERE, null, ex);
                ioError = ex.getMessage();
            }

            if (!addingelement) { 
                if (!"".equals(ioError)) {
                    addToLog("Impossibile aggiungere alla lista di invii la fattura numero " + r.getString("numero_fattura"));
                } else {
                    addToLog("Impossibile aggiungere alla lista di invii la fattura numero " + r.getString("numero_fattura") + ": " + ioError);
                }
            } else {
                System.out.println(r.getString("numero_fattura"));
            }

        } catch (ParseException ex) {
            System.out.println(ex.getMessage());
        }
    }

    return ftt;
}

Fattura( int id, String service, String email,  
         String name, String dateBill, String dateScad, String path, 
         int sent, String report, int billNumber, int idDocument) throws ParseException, IOException{

    this.id = id;
    this.service = service;
    this.email = email;
    this.name = name;
    this.path = path;
    this.report = report;
    this.sent = sent;
    this.billNumber = billNumber;

    this.dateBill = new SimpleDateFormat("yyyy-MM-dd").parse(dateBill);
    this.dateScad = new SimpleDateFormat("yyyy-MM-dd").parse(dateScad);
    this.idDocument = idDocument;

    this.pdfDocument = new PdfValidator(null, this.name, dateBill, String.valueOf(this.billNumber), String.valueOf(0), this.path);

}

내가 어디에서 틀렸는 지 아십니까? 감사

alain.janinm

yyyy 대신 YYYY 주를 사용하고 있습니다. SimpleDateFormat 문서를 살펴보십시오 . 모든 패턴과 몇 가지 유용한 예제를 찾을 수 있습니다.

이제 yyyy-MM-dd2014-12-09 만 구문 분석합니다. 날짜 이후에도 시간이 있다면 다음과 같이 사용해야합니다.yyyy-MM-dd HH:mm:ss.S

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

날짜 변환 오류 : JAVA에서 구문 분석 할 수없는 날짜

분류에서Dev

java 구문 분석 할 수없는 날짜 :

분류에서Dev

Java 구문 분석 할 수없는 날짜 예외

분류에서Dev

SimpleDateFormat java.text.ParseException : 구문 분석 할 수없는 날짜

분류에서Dev

CET가있는 날짜 : 구문 분석 할 수없는 날짜

분류에서Dev

Java 시간 오프셋으로 구문 분석 할 수없는 날짜 문제

분류에서Dev

java.text.ParseException : JAVA Android에서 구문 분석 할 수없는 날짜

분류에서Dev

Groovy는 문자열을 날짜로 구문 분석 할 수 없습니다.

분류에서Dev

구문 분석 할 수없는 날짜 java.text.ParseException : 구문 분석 할 수없는 날짜 : "2015-10-08 05 : 00 : 00.0"

분류에서Dev

java.text.ParseException : 구문 분석 할 수없는 날짜 : "01-02-2014"

분류에서Dev

java.text.ParseException : 구문 분석 할 수없는 날짜 : '2016 년 2 월 28 일'

분류에서Dev

ParseException : csv에서 날짜를 구문 분석하는 중 구문 분석 할 수없는 날짜 오류 (Windows)

분류에서Dev

날짜 형식화 시도 후 구문 분석 할 수없는 날짜 예외

분류에서Dev

구문 분석 할 수없는 간단한 날짜 형식

분류에서Dev

ParseException : 구문 분석 할 수없는 날짜

분류에서Dev

SimpleDateFormat으로 구문 분석 할 수없는 날짜

분류에서Dev

Android : 시작 4에서 구문 분석 할 수없는 날짜

분류에서Dev

구문 분석 할 수없는 날짜 오류

분류에서Dev

SimpleDateFormatter 구문 분석 할 수없는 날짜 예외

분류에서Dev

SimpleDateFormat ParseException : 구문 분석 할 수없는 날짜

분류에서Dev

구문 분석 할 수없는 날짜 : '요일 이름'(SimpleDateFormat)

분류에서Dev

문자열에서 날짜를 구문 분석 할 수 없습니다.

분류에서Dev

문자열을 날짜 형식으로 구문 분석 할 수 없습니다.

분류에서Dev

ISO-8601 날짜 문자열을 날짜로 구문 분석 할 수 없습니다.

분류에서Dev

날짜를 구문 분석 할 수 없습니다.

분류에서Dev

jQuery UI로 날짜를 구문 분석 할 수 없습니다.

분류에서Dev

RFC822 날짜를 구문 분석 할 수 없습니다.

분류에서Dev

SimpleDateFormat 구문 분석 할 수없는 날짜 : 구문 분석 방법을 사용하는 경우 "9-Jul"

분류에서Dev

WSO2 API Manager 문제 구문 분석 할 수없는 날짜

Related 관련 기사

  1. 1

    날짜 변환 오류 : JAVA에서 구문 분석 할 수없는 날짜

  2. 2

    java 구문 분석 할 수없는 날짜 :

  3. 3

    Java 구문 분석 할 수없는 날짜 예외

  4. 4

    SimpleDateFormat java.text.ParseException : 구문 분석 할 수없는 날짜

  5. 5

    CET가있는 날짜 : 구문 분석 할 수없는 날짜

  6. 6

    Java 시간 오프셋으로 구문 분석 할 수없는 날짜 문제

  7. 7

    java.text.ParseException : JAVA Android에서 구문 분석 할 수없는 날짜

  8. 8

    Groovy는 문자열을 날짜로 구문 분석 할 수 없습니다.

  9. 9

    구문 분석 할 수없는 날짜 java.text.ParseException : 구문 분석 할 수없는 날짜 : "2015-10-08 05 : 00 : 00.0"

  10. 10

    java.text.ParseException : 구문 분석 할 수없는 날짜 : "01-02-2014"

  11. 11

    java.text.ParseException : 구문 분석 할 수없는 날짜 : '2016 년 2 월 28 일'

  12. 12

    ParseException : csv에서 날짜를 구문 분석하는 중 구문 분석 할 수없는 날짜 오류 (Windows)

  13. 13

    날짜 형식화 시도 후 구문 분석 할 수없는 날짜 예외

  14. 14

    구문 분석 할 수없는 간단한 날짜 형식

  15. 15

    ParseException : 구문 분석 할 수없는 날짜

  16. 16

    SimpleDateFormat으로 구문 분석 할 수없는 날짜

  17. 17

    Android : 시작 4에서 구문 분석 할 수없는 날짜

  18. 18

    구문 분석 할 수없는 날짜 오류

  19. 19

    SimpleDateFormatter 구문 분석 할 수없는 날짜 예외

  20. 20

    SimpleDateFormat ParseException : 구문 분석 할 수없는 날짜

  21. 21

    구문 분석 할 수없는 날짜 : '요일 이름'(SimpleDateFormat)

  22. 22

    문자열에서 날짜를 구문 분석 할 수 없습니다.

  23. 23

    문자열을 날짜 형식으로 구문 분석 할 수 없습니다.

  24. 24

    ISO-8601 날짜 문자열을 날짜로 구문 분석 할 수 없습니다.

  25. 25

    날짜를 구문 분석 할 수 없습니다.

  26. 26

    jQuery UI로 날짜를 구문 분석 할 수 없습니다.

  27. 27

    RFC822 날짜를 구문 분석 할 수 없습니다.

  28. 28

    SimpleDateFormat 구문 분석 할 수없는 날짜 : 구문 분석 방법을 사용하는 경우 "9-Jul"

  29. 29

    WSO2 API Manager 문제 구문 분석 할 수없는 날짜

뜨겁다태그

보관