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

intgetMonthInt(String month)
Return month in int representation from String .
return Integer.parseInt(month);
StringgetNextDayStr(String curday)
get Next Day Str
java.util.Date date = str2utilDate(curday);
return date2str(new Date(date.getTime() + 24 * 3600 * 1000));
StringgetNextDayStr(String curday)
get Next Day Str
java.util.Date date = str2date(curday);
return date2str(new Date(date.getTime() + 24 * 3600 * 1000));
java.sql.DategetNow()
Get current date in sql format yyyy-MM-dd
Calendar cal = Calendar.getInstance(TimeZone.getDefault());
String DATE_FORMAT = "yyyy-MM-dd";
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(DATE_FORMAT);
sdf.setTimeZone(TimeZone.getDefault());
String now = sdf.format(cal.getTime());
return java.sql.Date.valueOf(now);
DategetNow()
get Now
Calendar cal = Calendar.getInstance();
return new Date(cal.getTimeInMillis());
StringgetNowHour()
get Now Hour
String nowHour = "";
try {
    String strTemp = getNowPlusTimeMill();
    nowHour = strTemp.substring(8, 10);
    return nowHour;
} catch (Exception e) {
    throw e;
ClassgetProtobufClass(Object value, Class protobufClass)
Retrieve the ProtobufClass based on the POJO value.
if (value instanceof Integer) {
    return Integer.TYPE;
if (value instanceof Boolean) {
    return Boolean.TYPE;
if (value instanceof Double) {
    return Double.TYPE;
...
ListgetTodayAndTomorrow()
get Today And Tomorrow
List<String> dates = new ArrayList<String>();
Calendar cal = Calendar.getInstance();
dates.add(new Date(cal.getTimeInMillis()).toString());
cal.add(Calendar.DATE, 1);
dates.add(new Date(cal.getTimeInMillis()).toString());
return dates;
intgetWeekNumber()
Gets the week number.
return (getLastSundayDate().get(Calendar.DAY_OF_YEAR)
        - getFirstSundayDateInYear(2009).get(Calendar.DAY_OF_YEAR)) / 7 + 1;
intgetWeekOfMonth(String year, String month, String day)
get Week Of Month
java.sql.Date myDate = getDate(year, month, day);
int index = 0;
try {
    Calendar cal = Calendar.getInstance();
    cal.setTime(myDate);
    index = cal.get(Calendar.DAY_OF_WEEK);
    if (index <= 1) {
        index = 7;
...