001/*002 * Copyright 2002-2013 the original author or authors.003 *004 * Licensed under the Apache License, Version 2.0 (the "License");005 * you may not use this file except in compliance with the License.006 * You may obtain a copy of the License at007 *008 * https://www.apache.org/licenses/LICENSE-2.0009 *010 * Unless required by applicable law or agreed to in writing, software011 * distributed under the License is distributed on an "AS IS" BASIS,012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.013 * See the License for the specific language governing permissions and014 * limitations under the License.015 */016017package org.springframework.format.datetime.joda;018019import java.util.TimeZone;020021import org.joda.time.Chronology;022import org.joda.time.DateTimeZone;023import org.joda.time.format.DateTimeFormatter;024025import org.springframework.context.i18n.LocaleContext;026import org.springframework.context.i18n.LocaleContextHolder;027import org.springframework.context.i18n.TimeZoneAwareLocaleContext;028029/**030 * A context that holds user-specific Joda-Time settings such as the user's031 * Chronology (calendar system) and time zone.032 *033 * <p>A {@code null} property value indicate the user has not specified a setting.034 *035 * @author Keith Donald036 * @since 3.0037 * @see JodaTimeContextHolder038 */039public class JodaTimeContext {040041 private Chronology chronology;042043 private DateTimeZone timeZone;044045046 /**047 * Set the user's chronology (calendar system).048 */049 public void setChronology(Chronology chronology) {050 this.chronology = chronology;051 }052053 /**054 * Return the user's chronology (calendar system), if any.055 */056 public Chronology getChronology() {057 return this.chronology;058 }059060 /**061 * Set the user's time zone.062 * <p>Alternatively, set a {@link TimeZoneAwareLocaleContext} on063 * {@link LocaleContextHolder}. This context class will fall back to064 * checking the locale context if no setting has been provided here.065 * @see org.springframework.context.i18n.LocaleContextHolder#getTimeZone()066 * @see org.springframework.context.i18n.LocaleContextHolder#setLocaleContext067 */068 public void setTimeZone(DateTimeZone timeZone) {069 this.timeZone = timeZone;070 }071072 /**073 * Return the user's time zone, if any.074 */075 public DateTimeZone getTimeZone() {076 return this.timeZone;077 }078079080 /**081 * Get the