Java 时间未正确转换为unix时间

Java 时间未正确转换为unix时间,java,android,unix,time,Java,Android,Unix,Time,我正试图根据time1和time2之间的值从数据库中检索一组值。因此,我将time1作为参数传递(在unix时间中),然后通过提取dd-MM-yyyy并将其添加到00:01来计算time2。本质上是,时间1-(从时间1开始的上午12点)。出于某种原因,从我的日期格式到unix时间的转换不正确。这是我的密码: public Cursor getValue(long time) throws ParseException { // Code to retrieve values steps fo

我正试图根据time1和time2之间的值从数据库中检索一组值。因此,我将time1作为参数传递(在unix时间中),然后通过提取dd-MM-yyyy并将其添加到00:01来计算time2。本质上是,时间1-(从时间1开始的上午12点)。出于某种原因,从我的日期格式到unix时间的转换不正确。这是我的密码:

public Cursor getValue(long time) throws ParseException {   // Code to retrieve values steps for every 1 hour
    SQLiteDatabase sqLiteDatabase = this.getReadableDatabase();
    Cursor cu;
    String time_current = String.valueOf(time);
   Log.d("Current Time",String.valueOf(new SimpleDateFormat("yyyy-MM-dd        HH:mm", Locale.getDefault()).format(time)));

    String time_past =  String.valueOf(new SimpleDateFormat("yyyy-MM-dd ", Locale.getDefault()).format(time)) + "00:01:00.000";
    Log.d("Past time", time_past);
    Date date= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", Locale.getDefault()).parse(time_past);

    Log.d("Time passed in time format", String.valueof(date.getTime());
    cu = sqLiteDatabase.rawQuery("select * from steps_table where time_steps between " + String.valueOf(date.getTime()) + " and " + (time_current)+";", null);
    return cu;
}

“以时间格式传递的时间”的日志显示为1461781860000。而2016-04-28 12:01应该是1461801660

1461801660
在我看来就像几秒钟。是的,所以我修改了代码以保存系统。currentTimeinMillis()/1000现在当我通过System.currentTimeinMillis()/1000时,它显示我的“当前时间”为1970-01-18 03:34。我的时区是IST。我假设“String.valueOf(new SimpleDateFormat(“yyyy-MM-dd-HH:MM”,Locale.getDefault()).format(time))”是错误的,因为这是在进行转换。yes-Date需要毫秒而不是秒。好的,即使我以相反的方式更正它。我的错误仍然存在。
1461801660
在我看来像是秒。是的,所以我更正了代码以保存系统。currentTimeinMillis()/1000现在,当我通过System.currentTimeinMillis()/1000时,它将我的“当前时间”显示为1970-01-18 03:34。我的时区是IST。我假设“String.valueOf(new SimpleDateFormat(“yyyy-MM-dd-HH:MM”,Locale.getDefault()).format(time))”是错误的,因为这是在进行转换。yes-Date需要毫秒而不是秒。好的,即使我以相反的方式更正它。我的错误仍然存在。