Java Day End getSCDEndDate()

Here you can find the source of getSCDEndDate()

Description

Returns the SCD end date: 2999-01-01 {Category} TimestampUtil {talendTypes} Date {example} getSCDEndDate().

License

Apache License

Declaration

public static Date getSCDEndDate() 

Method Source Code

//package com.java2s;
/**/* w  w  w  .j  a v a2 s  .com*/
 * Copyright 2015 Jan Lolling jan.lolling@gmail.com
 * 
 * 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.util.Calendar;
import java.util.Date;

public class Main {
    private static Date scdEndDate = null;

    /**
     * Returns the SCD end date: 2999-01-01
     * 
     * {Category} TimestampUtil
     * 
     * {talendTypes} Date
     * 
     * {example} getSCDEndDate().
     */
    public static Date getSCDEndDate() {
        if (scdEndDate == null) {
            scdEndDate = getIntAsDate(29990101);
        }
        return scdEndDate;
    }

    /**
     * getIntAsDate: returns the integer as date
     * 
     * {talendTypes} String
     * 
     * {Category} TimestampUtil
     * 
     * {param} Integer(date) date : date to format
     * 
     * {example} getIntAsDate(date) # 20150403
     */
    public static java.util.Date getIntAsDate(Integer dateAsInt) {
        if (dateAsInt != null) {
            java.util.Calendar c = java.util.Calendar.getInstance();
            // cut time
            c.set(java.util.Calendar.MINUTE, 0);
            c.set(java.util.Calendar.SECOND, 0);
            c.set(java.util.Calendar.MILLISECOND, 0);
            c.set(java.util.Calendar.HOUR_OF_DAY, 0);
            int year = dateAsInt / 10000;
            int monthDay = (dateAsInt - (year * 10000));
            int month = monthDay / 100;
            int day = monthDay % 100;
            c.set(Calendar.YEAR, year);
            c.set(Calendar.MONTH, month - 1);
            c.set(Calendar.DAY_OF_MONTH, day);
            return c.getTime();
        } else {
            return null;
        }
    }
}

Related

  1. getNextSendTime(Date sendDate, Date start)
  2. getNumberOfDaysBetweenDates(Date beginDate, Date endDate)
  3. getNumberOfMonthsBetween(final Date begin, final Date end)
  4. getNumMonths(Date dStart, Date dEnd)
  5. getNumYears(Date dStart, Date dEnd)
  6. getSecondSemesterEndDate(Integer year)
  7. getSendTime(Date sendDate, Date start, Date end)
  8. getStartAndEndDate(Date d)
  9. getStartOrEndTime(Date date, int flag)