Hallo WebViper,
Um GregorianCalender aus einem String zu konstruieren, musst Du aber noch die einzelnen Werte in ints casten.
und dann kannst Du doch den Konstruktor benutzen:
GregorianCalendar public GregorianCalendar(int year,
int month,
int date)
Constructs a GregorianCalendar with the given date set in the default time zone with the default locale.Parameters:
year - the value used to set the YEAR time field in the calendar.
month - the value used to set the MONTH time field in the calendar. Month value is 0-based. e.g., 0 for January.
date - the value used to set the DATE time field in the calendar.
Aber wenn Du das wie in dem Beispiel machst:
SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy");
Date datum = dateFormat.parse(eingangsdatum);
SimpleDateFormat dateFormatVergleich = new SimpleDateFormat("dd.MM.yyyy");
Date vergleichsDatum = dateFormat.parse(lieferdatum);
...
if datum.compareTo(vergleichsdatum < 0)
{
...
}
else
{
...
}
compareTo public int (Date anotherDate)
Compares two Dates for ordering.Parameters:anotherDate - the Date to be compared.Returns:the value 0 if the argument Date is equal to this Date; a value less than 0 if this Date is before the Date argument; and a value greater than 0 if this Date is after the Date argument.
so würd ich das machen, wenn ich zwei Strings hätte.
so long
Christoph