1/* 2 * Copyright 2012 Sebastian Annies, Hamburg 3 * 4 * Licensed under the Apache License, Version 2.0 (the License); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an AS IS BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16package com.googlecode.mp4parser.authoring; 17 18import java.util.Date; 19 20/** 21 * Converts ISO Dates (seconds since 1/1/1904) to Date and vice versa. 22 */ 23public class DateHelper { 24 /** 25 * Converts a long value with seconds since 1/1/1904 to Date. 26 * 27 * @param secondsSince seconds since 1/1/1904 28 * @return date the corresponding <code>Date</code> 29 */ 30 static public Date convert(long secondsSince) { 31 return new Date((secondsSince - 2082844800L) * 1000L); 32 } 33 34 35 /** 36 * Converts a date as long to a mac date as long 37 * 38 * @param date date to convert 39 * @return date in mac format 40 */ 41 static public long convert(Date date) { 42 return (date.getTime() / 1000L) + 2082844800L; 43 } 44} 45