com.abubusoft.kripton.common.CalendarUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kripton-core Show documentation
Show all versions of kripton-core Show documentation
Kripton Persistence Library - core module
/*******************************************************************************
* Copyright 2015, 2016 Francesco Benincasa.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.abubusoft.kripton.common;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.TimeZone;
public class CalendarUtils {
public static String FULL = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
public static String LONG = "yyyy-MM-dd HH:mm:ss z";
public static String NORMAL = "yyyy-MM-dd z";
public static String SHORT = "yyyy-MM-dd";
public static String TIME_ZONE = "GMT";
public static Calendar read(String value) {
Date date=DateUtils.read(value);
Calendar calendar=Calendar.getInstance();
calendar.setTime(date);
return calendar;
}
public static String write(Calendar value) {
return DateUtils.write(value.getTime());
}
static String getPattern(String text) {
int length = text.length();
if (length > 23) {
return FULL;
}
if (length > 20) {
return LONG;
}
if (length > 11) {
return NORMAL;
}
return SHORT;
}
public static class ThreadLocalDateFormatter {
private static final ThreadLocal
© 2015 - 2025 Weber Informatics LLC | Privacy Policy