Question

I'm creating a query using the SDK for Java.

I want to get the ID from 2 days ago until today.

String wiqlQuery = "Select ID from WorkItems where System.ChangedDate >= @Today-2";
WorkItemCollection workItems = workItemClient.query(wiqlQuery);

I've also tried with this example from the MSDN just to test clause the "WHERE" with dates:

String wiqlQuery = "Select ID from WorkItems where [System.ChangedDate] >= '1/8/06 GMT'";

I got the following message:

Exception in thread "main" java.lang.NullPointerException: timeZone must not be null

Reference: http://msdn.microsoft.com/en-us/library/bb130148%28v=vs.90%29.aspx

Could anyone help me on that?

Thanks in advance.

Was it helpful?

Solution

when connecting to TFS, you need to specify the ConnectionAdvisor. When no connection advisor is specified when creating a new instance of TFSTeamProjectCollection, a DefaultConnectionAdvisor is created with a default locale and time zone. Maybe it's not setting the default locale and time zone.

However, it's best to set the timezone in the defaultConnectionAdvisor.

ConnectionAdvisor connectionAdvisor = new DefaultConnectionAdvisor(Locale.US, TimeZone.getTimeZone("UTC"));
tpc = new TFSTeamProjectCollection(URIUtils.newURI(TFS_COLLECTION_URL), credentials, connectionAdvisor);

Hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top