Friday, August 10, 2012

Oracle Qrery for get time and update time

// Select 
select to_char(COL_NAME,'MM/DD/YYYY HH:MI:SS AM') from TABLE_NAME
// Update
update TABLE_NAME set COL_NAME=to_date('2012-07-30 11:13:39','MM/DD/YYYY HH:MI:SS AM')

To get coming Start of the day in java

public Date getComingStartoftheDay()
    {
        java.util.GregorianCalendar today = (GregorianCalendar) Calendar.getInstance();
        today.set(Calendar.HOUR_OF_DAY, 0);
        today.set(Calendar.MINUTE, 0);
        today.set(Calendar.SECOND, 0);
        today.set(Calendar.MILLISECOND, 0);

        Timestamp ts = new Timestamp(today.getTime().getTime()+86400000);
        Date date = new Date(ts.getTime());
        System.out.println(date);
        return date;
    }