Project

General

Profile

« Previous | Next » 

Revision bfa4bcb7

Added by Katja Luther almost 4 years ago

ref #8990: add formatter for extendedTimeperiod

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/strategy/cache/common/ExtendedTimePeriodPartialFormatter.java
1
/**
2
* Copyright (C) 2020 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.cdm.strategy.cache.common;
10

  
11
import org.joda.time.ReadablePartial;
12

  
13
import eu.etaxonomy.cdm.model.common.TimePeriod;
14

  
15
/**
16
 * @author k.luther
17
 * @since Jun 15, 2020
18
 */
19
public class ExtendedTimePeriodPartialFormatter extends TimePeriodPartialFormatter {
20

  
21
    public static ExtendedTimePeriodPartialFormatter NewInstance(){
22
        return new ExtendedTimePeriodPartialFormatter();
23
    }
24

  
25
    private ExtendedTimePeriodPartialFormatter(){
26
        super();
27
    }
28

  
29
    @Override
30
    public String print(ReadablePartial partial){
31
        //TODO
32
        String result = "";
33
        String year = (partial.isSupported(TimePeriod.YEAR_TYPE))? String.valueOf(partial.get(TimePeriod.YEAR_TYPE)):null;
34
        String month = (partial.isSupported(TimePeriod.MONTH_TYPE))? String.valueOf(partial.get(TimePeriod.MONTH_TYPE)):null;;
35
        String day = (partial.isSupported(TimePeriod.DAY_TYPE))? String.valueOf(partial.get(TimePeriod.DAY_TYPE)):null;;
36

  
37

  
38
        if (day != null){
39
            if (month == null){
40
                month = "xx";
41
            }
42

  
43
        }
44
        result = (day != null)? day + "." : "";
45
        result += (month != null)? month + "." : "";
46
        result += (year != null)? year : "";
47

  
48
        return result;
49
    }
50

  
51

  
52
}

Also available in: Unified diff