Java Utililty Methods SQL Time Create

List of utility methods to do SQL Time Create

Description

The list of methods to do SQL Time Create are organized into topic(s).

Method

intgetYear(String dateTime)
get Year
Calendar c = Calendar.getInstance();
c.setTime(getDateTime(dateTime));
int year = c.get(1);
return year;
intgetYear(String dateTime)
get Year
Calendar c = Calendar.getInstance();
c.setTime(getDateTime(dateTime));
int year = c.get(c.YEAR);
return year;
Timesubstract(Time thisDeparture, Time firstDeparture)
substract
Calendar firstCal = Calendar.getInstance(TimeZone.getDefault());
firstCal.setTime(firstDeparture);
Calendar secondCal = Calendar.getInstance(TimeZone.getDefault());
secondCal.setTime(thisDeparture);
secondCal.add(Calendar.HOUR_OF_DAY, 0 - firstCal.get(Calendar.HOUR_OF_DAY));
secondCal.add(Calendar.MINUTE, 0 - firstCal.get(Calendar.MINUTE));
secondCal.add(Calendar.SECOND, 0 - firstCal.get(Calendar.SECOND));
return new Time(secondCal.getTime().getTime());
...
TimeSumTime(Time t1, Time t2)
Suma dos tiempos pasados
long tm = 0;
String[] arr = t1.toString().split(":");
tm += Integer.parseInt(arr[2]);
tm += 60 * Integer.parseInt(arr[1]);
tm += 3600 * Integer.parseInt(arr[0]);
arr = t2.toString().split(":");
tm += Integer.parseInt(arr[2]);
tm += 60 * Integer.parseInt(arr[1]);
...
TimesumTimes(String[] timeStrings, DateFormat df)
sum Times
int secs = 0, mins = 0, hrs = 0;
Calendar calendar = Calendar.getInstance();
for (int i = 0; i < timeStrings.length; i++) {
    String dateString = timeStrings[i];
    Date date = new Date();
    try {
        date = (Date) df.parse(dateString);
    } catch (ParseException e) {
...
Doubletime2Double(java.sql.Time time)
time Double
if (time != null) {
    Calendar c = Calendar.getInstance();
    c.setTimeInMillis(time.getTime());
    double hour = c.get(Calendar.HOUR_OF_DAY);
    double minuten = c.get(Calendar.MINUTE);
    double sekunden = c.get(Calendar.SECOND);
    double minutendecimal = minuten / 60;
    double sekundendecimal = sekunden / 3600;
...
Stringtime2String(final java.sql.Time value)
Time to String format
return value.toString();
byte[]timeToBytes(Time t)
time To Bytes
Calendar cal = Calendar.getInstance();
cal.setTime(t);
byte[] b = new byte[8];
b[0] = (byte) 0;
b[1] = (byte) (19 & 0xff);
b[2] = (byte) (70 & 0xff);
b[3] = (byte) (1 & 0xff);
b[4] = (byte) (1 & 0xff);
...
CalendartimeToCalendar(Time input)
time To Calendar
java.util.Calendar output = Calendar.getInstance();
output.setTimeInMillis(input.getTime());
return output;
inttimeToInternal(java.sql.Time time)
Converts the Java type used for UDF parameters of SQL TIME type ( java.sql.Time ) to internal representation (int).
return timeToInternal(time, UTC_ZONE);