001package com.box.sdk; 002 003import java.util.Date; 004 005/** 006 * Class is used to be a range for two dates. Ususally paired with varying search filters. 007 * 008 */ 009public class DateRange { 010 private Date from; 011 private Date to; 012 013 /** 014 * Used for specify a date range to filter to be used in search. 015 * @param from is the start date in a range. 016 * @param to is the end date in a range. 017 */ 018 public DateRange(Date from, Date to) { 019 this.from = from; 020 this.to = to; 021 } 022 /** 023 * Returns the from date which is the start date. 024 * @return Date this is start date. 025 */ 026 public Date getFromDate() { 027 return this.from; 028 } 029 /** 030 * Set the from date which is equivalent to the start date. 031 * @param from date which is the starting point. 032 */ 033 public void setFrom(Date from) { 034 this.from = from; 035 } 036 /** 037 * Returns the to date which is the end date. 038 * @return Date this is the end date. 039 */ 040 public Date getToDate() { 041 return this.to; 042 } 043 /** 044 * Set the to date which is equivalent to the start date. 045 * @param to date which is the end point. 046 */ 047 public void setTo(Date to) { 048 this.to = to; 049 } 050 /** 051 * Used to build out a string a http box api friendly range string. 052 * @return String that is uses as a rest parameter. 053 */ 054 public String buildRangeString() { 055 056 String fromString = BoxDateFormat.format(this.from); 057 String toString = BoxDateFormat.format(this.to); 058 059 060 String rangeString = String.format("%s,%s", fromString, toString); 061 if (rangeString == ",") { 062 rangeString = null; 063 } 064 return rangeString; 065 } 066}