![]() |
Konvertieren von String zu Datum
Hallo zusammen,
ich habe eine Herausforderung in Java einen String in ein gültiges Datum zu konvertieren. Folgender Code:
Code:
Bei der Eingabe von:
public static String convertAnyDateFormat(String dateString,String sourceDateFormat,String targetDateFormat){
SimpleDateFormat sdf_source = new SimpleDateFormat(sourceDateFormat,Locale.ENGLISH); // Define instance of Source format SimpleDateFormat sdf_target = new SimpleDateFormat(targetDateFormat,Locale.ENGLISH); // Define instance of Target format String var_Date = ""; try{ var_Date = sdf_target.format(sdf_source.parse(dateString)); } catch(ParseException e){ System.out.println("Source Format not correct"); } return var_Date;
Code:
mit dem Datum "Mon Oct 13 00:00:00 CEST 2014" bekomme ich das Ergebnis "286.10.2014".
getDateFromString.convertAnyDateFormat(row2.Date, "EEE MMM dd HH:mm:ss zzzz yyyy", "DD.MM.YYYY");
Wo ist mein Denkfehler? Danke |
AW: Konvertieren von String zu Datum
targetDateFormat muss "dd.MM.YYYY" lauten, groß D ist für Day in year
|
AW: Konvertieren von String zu Datum
Hallo Stevie,
Zitat:
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 08:21 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz