Here you can find the source of converTimeToDayStartEnd(long time, long[] out)
Parameter | Description |
---|---|
time | a parameter |
public static long[] converTimeToDayStartEnd(long time, long[] out)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { /**//from w w w . j a va 2 s . com * convert a time to the corresponding time of the start and end of * the day it exists on. * * @param time * @return */ public static long[] converTimeToDayStartEnd(long time, long[] out) { Calendar cal = new GregorianCalendar(); Calendar calEnd = new GregorianCalendar(); cal.setTime(new Date(time)); cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0); calEnd.setTime(cal.getTime()); calEnd.add(Calendar.DATE, 1); // add one day to end date if (out == null) { return new long[] { cal.getTimeInMillis(), calEnd.getTimeInMillis() }; } else { out[0] = cal.getTimeInMillis(); out[1] = calEnd.getTimeInMillis(); return out; } } }