Java SQL Time Create getSqlTimeFromTimeNumber(int time)

Here you can find the source of getSqlTimeFromTimeNumber(int time)

Description

get Sql Time From Time Number

License

Open Source License

Declaration

public static Time getSqlTimeFromTimeNumber(int time) 

Method Source Code

//package com.java2s;
import java.sql.Time;

import java.util.Calendar;

public class Main {
    public static Time getSqlTimeFromTimeNumber(int time) {
        int leftover = time;

        final int hour = leftover / (60 * 60 * 1000);
        leftover -= hour * 60 * 60 * 1000;

        final int minute = leftover / (60 * 1000);
        leftover -= minute * 60 * 1000;/*from  w w  w . jav a  2 s  .  c o m*/

        final int second = leftover / 1000;
        leftover -= second * 1000;

        final int milli = leftover;

        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.HOUR, hour);
        calendar.set(Calendar.MINUTE, minute);
        calendar.set(Calendar.SECOND, second);
        calendar.set(Calendar.MILLISECOND, milli);

        return new Time(calendar.getTimeInMillis());
    }
}

Related

  1. getSqlTime(int hour, int minute, int second)
  2. getSQLTime(String timeString)
  3. getSQLTime(String value)
  4. getSQLTimeFromString(String s)
  5. getSysDateTimeMillis()
  6. getSystemCurrentTimeMillis()
  7. getSystemTimeGMTToday()
  8. getSysTime()