001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019 020package org.apache.isis.core.progmodel.facets.value; 021 022import java.util.List; 023import java.util.Locale; 024import java.util.StringTokenizer; 025 026import com.google.common.base.Function; 027import com.google.common.collect.Iterables; 028 029import org.joda.time.LocalDate; 030import org.joda.time.format.DateTimeFormatter; 031 032import org.apache.isis.applib.profiles.Localization; 033import org.apache.isis.core.metamodel.facets.object.parseable.TextEntryParseException; 034 035public final class JodaFunctions { 036 037 private JodaFunctions(){} 038 039 public static Function<DateTimeFormatter, DateTimeFormatter> withLocale(final Localization localization) { 040 return new Function<DateTimeFormatter, DateTimeFormatter>() { 041 @Override 042 public DateTimeFormatter apply(DateTimeFormatter input) { 043 if (localization == null) { 044 return input; 045 } 046 final Locale locale = localization.getLocale(); 047 if (locale == null) { 048 return input; 049 } 050 return input.withLocale(locale); 051 } 052 }; 053 } 054 055}