在Java应用程序的java.util.Date中获取Dropbox上文件的LastModified日期

时间:2013-12-28 07:47:35

标签: java dropbox dropbox-api

我正在开发一个应用程序,它将在Dropbox上获取文件的最后修改时间和日期,并且它将获得最后修改日期(文件的上传时间)和文件在本地计算机上的时间,然后在comaparing两个时间之后和日期,应用程序将决定是上传该文件还是从Dropbox下载。现在我坚持这个问题,我怎么能得到最后修改日期& Dropbox上特定文件的时间。

2 个答案:

答案 0 :(得分:2)

答案 1 :(得分:0)

private void GetServerModifiedTime(String my_token, String my_path_to_root_folder) throws IOException
{
    //create the new DropBox client
    DbxClientV2 my_dropbox_client = new DbxClientV2(new DbxRequestConfig("my_app_name_and_version"), my_token);


    List<Metadata> list_of_metadata_for_all_files = new ArrayList<Metadata>();

    try {
        //get a list of all files
        list_of_metadata_for_all_files = my_dropbox_client.files().listFolder(my_path_to_root_folder).getEntries();

        for (Metadata file_metadata : list_of_metadata_for_all_files)
        {
            if (!(file_metadata instanceof FolderMetadata)) {
                String file_name = file_metadata.getName();

                String root_path_plus_file_name = my_path_to_root_folder + "/" + file_name;

                FileMetadata file_meta_data = (FileMetadata) my_dropbox_client.files().getMetadata(root_path_plus_file_name);

                Date file_date = file_meta_data.getServerModified();

                long file_server_modified = file_date.getTime();

                Log.i("", "-------->" + file_server_modified + "\n");

            }
        }

    }catch (DbxException ignore){
        throw new IOException(ignore);
    }
}
相关问题