src/org/ohmage/request/survey/SurveyResponseFunctionReadRequest.java
private void subdivideDate(
			Map<PrivacyState, Collection<Collection<SurveyResponse>>> privacyStateBucket) {
		
		// For each of the privacy state buckets,
		for(PrivacyState privacyState : privacyStateBucket.keySet()) {
			// Get the current privacy state bucket.
			Collection<Collection<SurveyResponse>> currPrivacyStateBucket =
					privacyStateBucket.get(privacyState);
			
			// Create a new, empty privacy state bucket.
			Collection<Collection<SurveyResponse>> newPrivacyStateBucket =
					new LinkedList<Collection<SurveyResponse>>();
			
			// Subdivide each of the outer buckets by removing their inner 
			// buckets and replacing them with their subdivided counterparts.
			for(Collection<SurveyResponse> currBucket : currPrivacyStateBucket) {
				// Subdivide the inner collections.
				Map<String, Collection<SurveyResponse>> newInnerBuckets =
						new HashMap<String, Collection<SurveyResponse>>();
				
				// For all of the survey responses in this inner bucket, get
				// their survey ID and re-bucket them.
				for(SurveyResponse surveyResponse : currBucket) {
					// Create a calendar with the timezone from the response 
					// and set its time based on the epoch milliseconds.
					Calendar timezoneAdjustedCalendar =
							Calendar.getInstance(surveyResponse.getTimezone().toTimeZone());
					timezoneAdjustedCalendar.setTimeInMillis(
							surveyResponse.getTime());
					
					// Create the date string to represent this date based on
					// the creator's timezone at the time they took it.
					String dateString = 
							timezoneAdjustedCalendar.get(Calendar.YEAR) + 
							"-" +
							timezoneAdjustedCalendar.get(Calendar.MONTH) +
							"-" +
							timezoneAdjustedCalendar.get(Calendar.DAY_OF_MONTH);
					
					// Get the other responses on this date.
					Collection<SurveyResponse> currResponses = 
							newInnerBuckets.get(dateString);
					
					// If no other responses exist for this date, create
					// the list.
					if(currResponses == null) {
						currResponses = new LinkedList<SurveyResponse>();
						newInnerBuckets.put(dateString, currResponses);
					}
					
					// Add this response to the given date.
					currResponses.add(surveyResponse);
				}
				
				// Add the inner buckets to the collection of outer buckets.
				for(String date : newInnerBuckets.keySet()) {
					newPrivacyStateBucket.add(newInnerBuckets.get(date));
				}
			}
			
			privacyStateBucket.put(privacyState, newPrivacyStateBucket);
		}
	}
/**
	 * Subdivides the privacy state buckets into those that occurred on the 
	 * same date.
	 * 
	 * @param privacyStateBucket The map of privacy state to buckets of
	 * 							 collections of survey responses.
	 */
Subdivides the privacy state buckets into those that occurred on the
same date.

@param privacyStateBucket The map of privacy state to buckets of
collections of survey responses.
Subdivides the privacy state buckets into those that occurred on the same date . @param privacyStateBucket The map of privacy state to buckets of collections of survey responses .
private void subdivideDate(
			Map<PrivacyState, Collection<Collection<SurveyResponse>>> privacyStateBucket) {
		for(PrivacyState privacyState : privacyStateBucket.keySet()) {
			Collection<Collection<SurveyResponse>> currPrivacyStateBucket =
					privacyStateBucket.get(privacyState);
			Collection<Collection<SurveyResponse>> newPrivacyStateBucket =
					new LinkedList<Collection<SurveyResponse>>();
			for(Collection<SurveyResponse> currBucket : currPrivacyStateBucket) {
				Map<String, Collection<SurveyResponse>> newInnerBuckets =
						new HashMap<String, Collection<SurveyResponse>>();
				for(SurveyResponse surveyResponse : currBucket) {
					Calendar timezoneAdjustedCalendar =
							Calendar.getInstance(surveyResponse.getTimezone().toTimeZone());
					timezoneAdjustedCalendar.setTimeInMillis(
							surveyResponse.getTime());
					String dateString = 
							timezoneAdjustedCalendar.get(Calendar.YEAR) + 
							"-" +
							timezoneAdjustedCalendar.get(Calendar.MONTH) +
							"-" +
							timezoneAdjustedCalendar.get(Calendar.DAY_OF_MONTH);
					Collection<SurveyResponse> currResponses = 
							newInnerBuckets.get(dateString);
					if(currResponses == null) {
						currResponses = new LinkedList<SurveyResponse>();
						newInnerBuckets.put(dateString, currResponses);
					}
					currResponses.add(surveyResponse);
				}
				for(String date : newInnerBuckets.keySet()) {
					newPrivacyStateBucket.add(newInnerBuckets.get(date));
				}
			}
			privacyStateBucket.put(privacyState, newPrivacyStateBucket);
		}
	}
private void subdivideDate ( Map < PrivacyState , Collection < Collection < SurveyResponse > > > privacyStateBucket ) { for ( PrivacyState privacyState : privacyStateBucket . keySet ( ) ) { Collection < Collection < SurveyResponse > > currPrivacyStateBucket = privacyStateBucket . get ( privacyState ) ; Collection < Collection < SurveyResponse > > newPrivacyStateBucket = new LinkedList < Collection < SurveyResponse > > ( ) ; for ( Collection < SurveyResponse > currBucket : currPrivacyStateBucket ) { Map < String , Collection < SurveyResponse > > newInnerBuckets = new HashMap < String , Collection < SurveyResponse > > ( ) ; for ( SurveyResponse surveyResponse : currBucket ) { Calendar timezoneAdjustedCalendar = Calendar . getInstance ( surveyResponse . getTimezone ( ) . toTimeZone ( ) ) ; timezoneAdjustedCalendar . setTimeInMillis ( surveyResponse . getTime ( ) ) ; String dateString = timezoneAdjustedCalendar . get ( Calendar . YEAR ) + "-" + timezoneAdjustedCalendar . get ( Calendar . MONTH ) + "-" + timezoneAdjustedCalendar . get ( Calendar . DAY_OF_MONTH ) ; Collection < SurveyResponse > currResponses = newInnerBuckets . get ( dateString ) ; if ( currResponses == null ) { currResponses = new LinkedList < SurveyResponse > ( ) ; newInnerBuckets . put ( dateString , currResponses ) ; } currResponses . add ( surveyResponse ) ; } for ( String date : newInnerBuckets . keySet ( ) ) { newPrivacyStateBucket . add ( newInnerBuckets . get ( date ) ) ; } } privacyStateBucket . put ( privacyState , newPrivacyStateBucket ) ; } }
Subdivides the privacy state buckets into those that occurred on the
 same date.
Subdivides the privacy state buckets into those that occurred on the same date .
// For each of the privacy state buckets, // Get the current privacy state bucket. // Create a new, empty privacy state bucket. // Subdivide each of the outer buckets by removing their inner  // buckets and replacing them with their subdivided counterparts. // Subdivide the inner collections. // For all of the survey responses in this inner bucket, get // their survey ID and re-bucket them. // Create a calendar with the timezone from the response  // and set its time based on the epoch milliseconds. // Create the date string to represent this date based on // the creator's timezone at the time they took it. // Get the other responses on this date. // If no other responses exist for this date, create // the list. // Add this response to the given date. // Add the inner buckets to the collection of outer buckets.