Java Utililty Methods SQL Date

List of utility methods to do SQL Date

Description

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

Method

DategetDayOfPerMonth(String theDataStr)
get Day Of Per Month
Date theDate = java.sql.Date.valueOf(theDataStr);
Calendar c = new GregorianCalendar();
c.setTime(theDate);
int day = c.get(Calendar.DAY_OF_MONTH);
if (day <= 10) {
    c.set(Calendar.DAY_OF_MONTH, 1);
} else if (day > 10 && day <= 20) {
    c.set(Calendar.DAY_OF_MONTH, 11);
...
intgetDiffDays(String begin_dt, String end_dt)
get Diff Days
Date end = java.sql.Date.valueOf(end_dt);
Date begin = java.sql.Date.valueOf(begin_dt);
int days = getDaysBetween(begin, end);
return days;
ListgetEndWeekDayOfMonth(String year, String month)
get End Week Day Of Month
List list = new ArrayList();
String date = "";
int days = daysInMonth(year, month);
int weekday = 0;
for (int i = 1; i <= days; i++) {
    weekday = getWeekOfMonth(year, month, String.valueOf(i));
    if (weekday == 5) {
        if (i < 10) {
...
StringgetFileName()
get File Name
String fileName = "";
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
Date curDate = new Date(System.currentTimeMillis());
fileName = formatter.format(curDate) + ".png";
return fileName;
StringgetFirstDayOfNextMonth()
get First Day Of Next Month
try {
    return increaseYearMonth(getNowShortDate().substring(0, 6)) + "01";
} catch (Exception e) {
    return "";
StringgetFirstDayOfThisMonth()
get First Day Of This Month
try {
    return getNowShortDate().substring(0, 6) + "01";
} catch (Exception e) {
    return "";
StringgetInsertarEmpleado()
get Insertar Empleado
return "INSERT INTO tblempleado( id_empleado, nombre, apellidos, fecha_n, telefono, direccion, email, estado, id_cargo, id_empresa) values (?,?,?,?,?,?,?,?,?,?)";
StringgetInsertarEntrada()
get Insertar Entrada
return "INSERT INTO tblentrada_salida( id_empleado, cons, hora_entrada, hora_salida, fecha, id_empresa) values (?,?,?,?,?,?)";
longgetIntervalDays(String sd, String ed)
get Interval Days
return ((java.sql.Date.valueOf(ed)).getTime() - (java.sql.Date.valueOf(sd)).getTime()) / (3600 * 24 * 1000);
StringgetLastDay()
get Last Day
Calendar c = Calendar.getInstance();
c.setTime(getNowDate());
int today = c.get(5);
c.set(5, today - 1);
String lastDay = new SimpleDateFormat("yyyyMMdd").format(c.getTime());
return lastDay;