Mercurial > hg > openmind
changeset 127:3e772f7f43e0 default tip
ismi-date with long month names in xml dump.
author | Robert Casties <casties@mpiwg-berlin.mpg.de> |
---|---|
date | Thu, 11 May 2023 18:15:45 +0200 |
parents | 7d1e61a6d91b |
children | |
files | src/main/java/org/mpi/openmind/repository/utils/OM4StreamWriter.java src/main/java/org/mpi/openmind/repository/utils/ismi/ISMICalendar.java src/main/java/org/mpi/openmind/repository/utils/ismi/ISMIDate.java |
diffstat | 3 files changed, 51 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/org/mpi/openmind/repository/utils/OM4StreamWriter.java Fri Feb 10 10:21:29 2023 +0100 +++ b/src/main/java/org/mpi/openmind/repository/utils/OM4StreamWriter.java Thu May 11 18:15:45 2023 +0200 @@ -40,7 +40,7 @@ */ public class OM4StreamWriter { - protected static final String FORMAT_VERSION = "4.14"; + protected static final String FORMAT_VERSION = "4.15"; private static Logger logger = Logger.getLogger(OM4StreamWriter.class); @@ -539,7 +539,7 @@ writer.writeAttribute("date", date.getFromGregorian().getDateTime().toString(isodateFormatter)); } // textual date as content - writer.writeCharacters(date.toShortString()); + writer.writeCharacters(date.toLongerString()); writer.writeEndElement(); return true; }
--- a/src/main/java/org/mpi/openmind/repository/utils/ismi/ISMICalendar.java Fri Feb 10 10:21:29 2023 +0100 +++ b/src/main/java/org/mpi/openmind/repository/utils/ismi/ISMICalendar.java Thu May 11 18:15:45 2023 +0200 @@ -196,6 +196,52 @@ return str; } + /** + * Returns date as String in the form "YY MMMM DD". + * + * @return + */ + private String dateToString(ISMIDate date) { + int year = date.getYear(); + int month = date.getMonth(); + String monthName = "UNKNOWN"; + int day = date.getDayOfMonth(); + if (calendarType.equals(ISMICalendar.TYPE_GREGORIAN)) { + monthName = ISMIDate.gregorianMonths.get(month).replaceAll(" \\(\\d+\\)", ""); + } else if (calendarType.equals(ISMICalendar.TYPE_ISLAMIC)) { + monthName = ISMIDate.islamicMonths.get(month).replaceAll(" \\(\\d+\\)", ""); + } else if (calendarType.equals(ISMICalendar.TYPE_JULIAN)) { + monthName = ISMIDate.gregorianMonths.get(month).replaceAll(" \\(\\d+\\)", ""); + } + return String.format("%d %s %d", year, monthName, day); + } + + + public String toLongerString() { + String str = ""; + if (inputForm == null) return "UNKNOWN TYPE"; + if (inputForm.equals(INPUT_FORM_DATE)) { + // type date + str = dateToString(currentFrom); + } else if (inputForm.equals(INPUT_FORM_RANGE)) { + // type range + str = dateToString(currentFrom) + + " - " + + dateToString(currentUntil); + } else if (inputForm.equals(INPUT_FORM_YEAR)) { + // type year + str = currentYear.toString(); + } + if (calendarType.equals(TYPE_ISLAMIC)) { + str += " (islamic)"; + } else if (calendarType.equals(TYPE_JULIAN)) { + str += " (julian)"; + } else if (calendarType.equals(TYPE_GREGORIAN)) { + str += " (gregorian)"; + } + return str; + } + public String getFormattedRange(){ if(inputForm != null){ String from = this.fromGregorian.toString();
--- a/src/main/java/org/mpi/openmind/repository/utils/ismi/ISMIDate.java Fri Feb 10 10:21:29 2023 +0100 +++ b/src/main/java/org/mpi/openmind/repository/utils/ismi/ISMIDate.java Thu May 11 18:15:45 2023 +0200 @@ -17,9 +17,9 @@ public static String AMBIGUITY = "2"; - private static Map<Integer, String> gregorianMonths = new HashMap<Integer, String>(12); - private static Map<Integer, String> islamicMonths = new HashMap<Integer, String>(12); - private static Map<Integer, String> julianMonths = new HashMap<Integer, String>(12); + static Map<Integer, String> gregorianMonths = new HashMap<Integer, String>(12); + static Map<Integer, String> islamicMonths = new HashMap<Integer, String>(12); + static Map<Integer, String> julianMonths = new HashMap<Integer, String>(12); static{