Recently I am trying to populate a Google query via a properties file and I have written these lines of code:
public String getPropValues() throws IOException {
String result = "";
Properties prop = new Properties();
String propFileName = "config.properties";
InputStream inputStream = getClass().getClassLoader().getResourceAsStream(propFileName);
prop.load(inputStream);
if (inputStream == null) {
throw new FileNotFoundException("property file '" + propFileName + "' not found in the classpath");
}
Date time = new Date(System.currentTimeMillis());
// Get the property value and print it out
String user = prop.getProperty("user");
String company1 = prop.getProperty("startDate");
String company2 = prop.getProperty("endDate");
String company3 = prop.getProperty("company3");
result = "Company List = " + company1 + ", " + company2 + ", " + company3;
System.out.println(result + "\nProgram Ran on " + time + " by user=" + user);
return result;
}
to grab the data from properties
private static GaData executeDataQuery(Analytics analytics, String profileId) throws IOException {
return analytics.data().ga().get("ga:" + profileId, // Table Id. ga: + profile id.
"2014-05-19", // Start date.
"2014-05-20", // End date.
"ga:pageviews,ga:sessions,ga:uniquePageviews") // Metrics.
.setDimensions("ga:date")
.setSort("-ga:date")
.setMaxResults(25)
.execute();
}
This is the query that I am working with, so how do I make it so that I can enter the date into the properties file so that it will link it to the fields on my query?