Java Timestamp getTimeFromTimestamp( java.sql.Timestamp tsZeitpunkt)

Here you can find the source of getTimeFromTimestamp( java.sql.Timestamp tsZeitpunkt)

Description

get Time From Timestamp

License

Open Source License

Declaration

public final static java.sql.Time getTimeFromTimestamp(
            java.sql.Timestamp tsZeitpunkt) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * HELIUM V, Open Source ERP software for sustained success
 * at small and medium-sized enterprises.
 * Copyright (C) 2004 - 2014 HELIUM V IT-Solutions GmbH
 * /*ww w.j a v a  2s.c o  m*/
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published 
 * by the Free Software Foundation, either version 3 of theLicense, or 
 * (at your option) any later version.
 * 
 * According to sec. 7 of the GNU Affero General Public License, version 3, 
 * the terms of the AGPL are supplemented with the following terms:
 * 
 * "HELIUM V" and "HELIUM 5" are registered trademarks of 
 * HELIUM V IT-Solutions GmbH. The licensing of the program under the 
 * AGPL does not imply a trademark license. Therefore any rights, title and
 * interest in our trademarks remain entirely with us. If you want to propagate
 * modified versions of the Program under the name "HELIUM V" or "HELIUM 5",
 * you may only do so if you have a written permission by HELIUM V IT-Solutions 
 * GmbH (to acquire a permission please contact HELIUM V IT-Solutions
 * at trademark@heliumv.com).
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * Contact: developers@heliumv.com
 ******************************************************************************/

import java.util.Calendar;

public class Main {
    private final static long MILLISEKUNDEN_EINER_STUNDE = 3600000;
    private final static long MILLISEKUNDEN_EINER_MINUTE = 60000;
    private final static long MILLISEKUNDEN_EINER_SEKUNDE = 1000;

    public final static java.sql.Time getTimeFromTimestamp(
            java.sql.Timestamp tsZeitpunkt) {
        if (tsZeitpunkt == null) {
            return null;
        }
        Calendar c = Calendar.getInstance();
        c.setTimeInMillis(tsZeitpunkt.getTime());

        long l = -MILLISEKUNDEN_EINER_STUNDE; // Time faengt bei -36000000 an
        l += c.get(Calendar.HOUR_OF_DAY) * MILLISEKUNDEN_EINER_STUNDE;
        l += c.get(Calendar.MINUTE) * MILLISEKUNDEN_EINER_MINUTE;
        l += c.get(Calendar.SECOND) * MILLISEKUNDEN_EINER_SEKUNDE;
        l += c.get(Calendar.MILLISECOND);

        java.sql.Time t = new java.sql.Time(l);

        return t;

    }
}

Related

  1. getCurrTimestamp()
  2. getCurTime2Timestamp()
  3. getCurTimestamp()
  4. getCurTimestamp()
  5. getTimeDifference(Timestamp startTime, Timestamp endTime)
  6. getTimeNanoSec(Timestamp t)
  7. getTimeNextDay(Timestamp date)
  8. getTimeNextMonthFirstSec(Timestamp sysDate)
  9. getTimePassedSince(Timestamp timestamp)