Java Timestamp Field getEndTimeStampOfDate(Date date)

Here you can find the source of getEndTimeStampOfDate(Date date)

Description

get End Time Stamp Of Date

License

Open Source License

Declaration

public static Date getEndTimeStampOfDate(Date date) 

Method Source Code

//package com.java2s;
/**// w w  w  .j  a va  2 s  .c o m
 * Copyright (c) 2008 OpenSprout Team.
 * 
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 */

import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.SimpleDateFormat;

import java.util.Date;
import java.util.GregorianCalendar;
import java.util.StringTokenizer;

public class Main {
    public static Date getEndTimeStampOfDate(Date date) {
        if (date == null)
            return null;
        String yyyymmdd = makeYYYYMMDD(date);
        StringTokenizer tokenizer = new StringTokenizer(yyyymmdd, "/");
        int year = Integer.parseInt(tokenizer.nextToken());
        int month = Integer.parseInt(tokenizer.nextToken());
        int day = Integer.parseInt(tokenizer.nextToken());
        return new Timestamp(makeDateTime(year, month, day, 23, 59, 59).getTime());
    }

    public static String makeYYYYMMDD(Date date) {
        DateFormat format = new SimpleDateFormat("yyyy/MM/dd");
        return format.format(date);
    }

    public static Date makeDateTime(int year, int month, int day, int hour, int minute, int second) {
        return new GregorianCalendar(year, month - 1, day, hour, minute, second).getTime();
    }
}

Related

  1. getDouble(Timestamp ts)
  2. getDuration(final Timestamp start, final Date end)
  3. getDurationHour(Timestamp time1, Timestamp time2, String direction)
  4. getDurationMinute(Timestamp createTime, Timestamp finishTime)
  5. getEndTimeOfMonth(Timestamp timestamp)
  6. getFormattedDateTimeColumn(final Timestamp ts, final SimpleDateFormat formatDate)
  7. getFormattedTimeStamp(long millisSince1970)
  8. getFromTimestamp(Timestamp timestamp)
  9. getHms(Timestamp timestamp)