com.launchkey.sdk.transport.v1.domain.LaunchKeyDateFormat Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of launchkey-sdk Show documentation
Show all versions of launchkey-sdk Show documentation
SDK for interacting with the LaunchKey distributed authentication and authorization platform
/**
* Copyright 2015 LaunchKey, Inc. All rights reserved.
*
* Licensed under the MIT License.
* You may not use this file except in compliance with the License.
* A copy of the License is located in the "LICENSE.txt" file accompanying
* this file. This file 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.launchkey.sdk.transport.v1.domain;
import java.text.*;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
public class LaunchKeyDateFormat extends Format {
private static LaunchKeyDateFormat instance;
private final SimpleDateFormat formatter;
static LaunchKeyDateFormat getInstance() {
if (instance == null) {
instance = new LaunchKeyDateFormat();
}
return instance;
}
public LaunchKeyDateFormat() {
this.formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US);
this.formatter.setTimeZone(TimeZone.getTimeZone("GMT"));
}
public String format(Date obj) {
return super.format((Object) obj);
}
public Date parseObject(String source) throws ParseException {
return (Date) super.parseObject(source);
}
@Override
public StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos) {
return this.formatter.format(obj, toAppendTo, pos);
}
@Override
public Object parseObject(String source, ParsePosition pos) {
return this.formatter.parseObject(source, pos);
}
}