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