Here is a code snippet of getting the sql timestamp for the last calender day
We can also modify the timing in date(currrent or previous), hour, minute or seconds by adding the positive or negative number.
Calendar todayDate = Calendar.getInstance();
todayDate.add(Calendar.DATE, -1);
todayDate.set(Calendar.HOUR_OF_DAY, 0);
todayDate.set(Calendar.MINUTE, 0); // set minute in hour
todayDate.set(Calendar.SECOND, 0); // set second in minute
todayDate.set(Calendar.MILLISECOND, 0);
Date currentDate=todayDate.getTime();
long miliseconds=currentDate.getTime();
java.sql.Timestamp lastDayDate = new java.sql.Timestamp(miliseconds);
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment