Here you can find the source of convert(long time)
public static int convert(long time)
//package com.java2s; /*/*from w w w .ja v a 2 s . c om*/ * Copyright 2012 International Health Terminology Standards Development Organisation. * * 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. */ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { private static int timeZeroInt = 1830407753; private static ThreadLocal<SimpleDateFormat> dateFormatterTL = new ThreadLocal<>(); public static int convert(long time) { if (time == Long.MAX_VALUE) { return Integer.MAX_VALUE; } if (time == Long.MIN_VALUE) { return Integer.MIN_VALUE; } int timeInSec = (int) (time / 1000); return timeInSec - timeZeroInt; } public static long convert(int version) { if (version == Integer.MAX_VALUE) { return Long.MAX_VALUE; } if (version == Integer.MIN_VALUE) { return Long.MIN_VALUE; } long added = timeZeroInt + version; return added * 1000; } public static int convert(String dateStr) throws ParseException { if (dateStr.equalsIgnoreCase("latest")) { return Integer.MAX_VALUE; } SimpleDateFormat formatter = dateFormatterTL.get(); if (formatter == null) { formatter = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss"); dateFormatterTL.set(formatter); } Date d = formatter.parse(dateStr); return convert(d.getTime()); } }