package de.rainu.giskis.netxml;

import javax.xml.bind.annotation.adapters.XmlAdapter;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Locale;

/**
 * This {@link XmlAdapter} is responsible for un/marshalling {@link LocalDateTime} based on the kismet used date format.
 */
public class KismetTimeAdapter extends XmlAdapter<String, LocalDateTime> {
	private static DateTimeFormatter FORMAT = DateTimeFormatter.ofPattern("E MMM dd HH:mm:ss yyyy").withLocale(Locale.US);

	@Override
	public LocalDateTime unmarshal(String s) throws Exception {
		return LocalDateTime.parse(s, FORMAT);
	}

	@Override
	public String marshal(LocalDateTime localDateTime) throws Exception {
		if(localDateTime == null) {
			return "";
		}

		return localDateTime.format(FORMAT);
	}
}

@@ -578,16 +578,289 @@
 ption %7B%0A
+%09%09s = s.replace(%22  1 %22, %22 01 %22)%0A%09%09%09  .replace(%22  2 %22, %22 02 %22)%0A%09%09%09  .replace(%22  3 %22, %22 03 %22)%0A%09%09%09  .replace(%22  4 %22, %22 04 %22)%0A%09%09%09  .replace(%22  5 %22, %22 05 %22)%0A%09%09%09  .replace(%22  6 %22, %22 06 %22)%0A%09%09%09  .replace(%22  7 %22, %22 07 %22)%0A%09%09%09  .replace(%22  8 %22, %22 08 %22)%0A%09%09%09  .replace(%22  9 %22, %22 09 %22);%0A
 %09%09return

handle exception in parsing of the first 9 dates of month