import java.text.ParsePosition;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.Optional;

public class Main {
	public static void main(String[] args) {
		String english = "Your Last Login was 2013/10/04 13:06:45 ( 0 Days, 0 Hours, 0 Minutes )";
		String chinese = "您上次登录是 2013/10/04 13:06:45（ 0 天， 0 小时 0 分钟 ）";

		// Processing english
		Optional<LocalDateTime> date = getDateTime(english);
		date.ifPresent(dt -> System.out.printf("Year: %d, Month: %d, Day: %d, Hour: %d, Minute: %d, Second: %d%n",
				dt.getYear(), dt.getMonthValue(), dt.getDayOfMonth(), dt.getHour(), dt.getMinute(), dt.getSecond()));

		// Processing chinese
		date = getDateTime(chinese);
		date.ifPresent(dt -> System.out.printf("Year: %d, Month: %d, Day: %d, Hour: %d, Minute: %d, Second: %d%n",
				dt.getYear(), dt.getMonthValue(), dt.getDayOfMonth(), dt.getHour(), dt.getMinute(), dt.getSecond()));
	}

	static Optional<LocalDateTime> getDateTime(String s) {
		// Assuming the date-time string is in the format, yyyy/MM/dd HH:mm:ss
		DateTimeFormatter dtf = DateTimeFormatter.ofPattern("uuuu/M/d H:m:s");
		
		Optional<LocalDateTime> result = Optional.empty();
		for (int i = 0; i < s.length(); i++) {
			try {
				result = Optional.ofNullable(LocalDateTime.from(dtf.parse(s, new ParsePosition(i))));
				break;
			} catch (DateTimeParseException | IndexOutOfBoundsException e) {
			}
		}
		return result;
	}
}