Java SQL Time DateTimeSpace(String starttime, String endtime)

Here you can find the source of DateTimeSpace(String starttime, String endtime)

Description

Date Time Space

License

Open Source License

Declaration

public static long DateTimeSpace(String starttime, String endtime) 

Method Source Code


//package com.java2s;
import java.text.*;

public class Main {

    public static long DateTimeSpace(String starttime, String endtime) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        long starttimes = 0;
        long endtimes = 0;
        long spacetime = 0;
        try {/*  ww w .ja  v  a  2  s  . c  om*/
            starttimes = sdf.parse(starttime).getTime();
            endtimes = sdf.parse(endtime).getTime();
        } catch (ParseException e) {
            System.out.println(e);
        }

        spacetime = Math.abs(endtimes - starttimes) / 1000 / 60;
        return spacetime;
    }

    public String getTime() {
        java.sql.Time ent = new java.sql.Time(System.currentTimeMillis());
        return ent.toString();
    }
}

Related

  1. compareTime(String time1, String time2)
  2. createTime(int hour, int minute, int second)
  3. dateTime2str(java.sql.Date date)
  4. dateTimeFormat(Date date,String pattern)
  5. dateTimeToStr(java.util.Date date)
  6. daytime()
  7. deserializeSqlTime(String text)
  8. double2Time(Number zahl)