Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8212865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:54:56+00:00 2026-06-07T10:54:56+00:00

I am trying to write a method which takes a file path and a

  • 0

I am trying to write a method which takes a file path and a revision number as its arguments and returns the date the revision is associated with. The code I have works (although pretty slowely) however, when I put a revision number greater than 51 in, the output gets messed up.. Here is the API.

Input

String [] filePaths= {"//file/x/y/strings/somefile.csv"};
p4Client.getDateAssociatedWithFileRevision(filePaths, 52);

Output – This should just be one line…

Rev number: 2 :: Revision Date: Wed Aug 24 23:48:42 BST 2005

Rev number: 52 :: Revision Date: Wed Aug 24 23:52:53 BST 2005

Rev number: 51 :: Revision Date: Sat Aug 20 02:01:59 BST 2005

getDateAssociatedWithFileRevision

public Date getDateAssociatedWithFileRevision(String [] filePath, int revisionNumber) {

        List<IFileSpec> fileList = null;
        Map<IFileSpec,List<IFileRevisionData>> fileRevisionData = null;
        String currentFile = null;
        Date revisionDate = null;

        try 
        {
            String file = filePath[0] + "#" + revisionNumber;
            currentFile = file;
            fileList = getIFileSpecList(file);  //Get list of file(s) in path

            for(IFileSpec fileSpec: fileList)
            {
                if(file.toString() == null)
                {
                    System.out.println("\"" + currentFile +"\"" + " does not exist...");
                    break;
                }
                fileRevisionData = fileSpec.getRevisionHistory(0, true,false,true,false);
                int i = 0;
                for(List<IFileRevisionData> revisionData : fileRevisionData.values()) {
                    revisionDate = revisionData.get(0).getDate();
                    int revision = revisionData.get(0).getRevision();
                    System.out.println("Rev number: " +revision +" :: " + "Revision Date: " + revisionDate);
                    System.out.println(i);
                    i++;
                }

            }
        }
        catch(Exception e){e.printStackTrace();}
        return revisionDate;  
     }

GetIFileSpecList

public List<IFileSpec> getIFileSpecList(String file) {
        List<IFileSpec> fileList = null;
        try {
            fileList = iServer.getDepotFiles(
                        FileSpecBuilder.makeFileSpecList(new String[] {file}), false);  //Get list of file(s) in path
        }
        catch(Exception e){e.printStackTrace();}
        return fileList;
     }

Edit

Just figured out that the output is getting messed up after an integration, just need to find a way to handle them now..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T10:54:57+00:00Added an answer on June 7, 2026 at 10:54 am

    I managed to return only the date I want by adding an if statement (marked below). I don’t know how elegant this solution is… any comments are welcome.

    getDateAssociatedWithFileRevision

    public Date getDateAssociatedWithFileRevision(String [] filePath, int revisionNumber) {
    
            List<IFileSpec> fileList = null;
            Map<IFileSpec,List<IFileRevisionData>> fileRevisionData = null;
            String currentFile = null;
            Date revisionDate = null;
    
            try 
            {
                String file = filePath[0] + "#" + revisionNumber;
                currentFile = file;
                fileList = getIFileSpecList(file);  //Get list of file(s) in path
    
                for(IFileSpec fileSpec: fileList)
                {
                    if(file.toString() == null)
                    {
                        System.out.println("\"" + currentFile +"\"" + " does not exist...");
                        break;
                    }
                    fileRevisionData = fileSpec.getRevisionHistory(0, true,false,true,false);
                    for(List<IFileRevisionData> revisionData : fileRevisionData.values()) {
                        int revision = revisionData.get(0).getRevision();
         -------------> if(revision.equals(revisionNumber))
                        {
                            revisionDate = revisionData.get(0).getDate();
    
                            System.out.println("Rev number: " +revision +" :: " + "Revision Date: " + revisionDate);
                            break;
    
                        }
                    }
    
                }
            }
            catch(Exception e){e.printStackTrace();}
            return revisionDate;  
         }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a method which takes a Map[K, Collection[V]] and converts it
I am trying to write a unit test for a method which takes an
I need to write a method which takes any object and returns an equivalent
I'm trying to write a custom fadeTo(component, x, y):void method, which takes an arbitrary
I am trying to write a controller method and a corresponding view which will
I'm trying to write a method that acts as a setter and takes some
I am trying to write a method, that takes a ComboBox, a DataTable and
I am trying to write a method that makes a log.txt file if one
I'm trying to write a method that takes in a base k and a
I am trying to write a snippet of code that takes a URL and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.