From Oracle Date to Unix epoch
select ( TO_DATE('2010-06-29', 'YYYY-MM-DD')- TO_DATE('1970-01-01', 'YYYY-MM-DD')) * 86400000 from dual;
From UNIX epoch to Oracle date
select TO_DATE('1970-01-01', 'YYYY-MM-DD') + 1277769600000 / 86400000 from dual
JAVA
=====
package mypackage;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class TestClear
{
public TestClear()
{
}
public String getUnixTime1()
{
java.lang.Long unixTime= new Long(System.currentTimeMillis()/1000L);
String unixTimeString = new String(""+unixTime);
//return unixTimeString.substring(0,6);
return unixTimeString;
}
public int getUnixTime2()
{
int year = 2010;
int month = 5;
int date = 29;
Calendar cal = Calendar.getInstance();
cal.clear();
cal.set(Calendar.YEAR, year);
cal.set(Calendar.MONTH, month);
cal.set(Calendar.DATE, date);
java.util.Date utilDate = cal.getTime();
java.lang.Long unixTime= new Long(cal.getTimeInMillis()/1000L);
String unixTimeString = new String(""+unixTime);
unixTimeString= unixTimeString.substring(0,5);
int unixTimeInt = Integer.parseInt(unixTimeString);
return unixTimeInt;
}
/**
*
* @param args
*/
public static void main(String[] args)
{
TestClear t= new TestClear();
System.out.println(t.getUnixTime2());
}
}