本文整理匯總了Java中org.joda.time.DateTime.withMillisOfSecond方法的典型用法代碼示例。如果您正苦於以下問題:Java DateTime.withMillisOfSecond方法的具體用法?Java DateTime.withMillisOfSecond怎麽用?Java DateTime.withMillisOfSecond使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.joda.time.DateTime
的用法示例。
在下文中一共展示了DateTime.withMillisOfSecond方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: alignRangeBoundary
import org.joda.time.DateTime; //導入方法依賴的package包/類
/**
For YEARS, MONTHS, WEEKS, DAYS:
Computes the timestamp of the first millisecond of the day
of the timestamp.
For HOURS,
Computes the timestamp of the first millisecond of the hour
of the timestamp.
For MINUTES,
Computes the timestamp of the first millisecond of the minute
of the timestamp.
For SECONDS,
Computes the timestamp of the first millisecond of the second
of the timestamp.
For MILLISECONDS,
returns the timestamp
@param timestamp
@return
*/
@SuppressWarnings("fallthrough")
private long alignRangeBoundary(long timestamp)
{
DateTime dt = new DateTime(timestamp, m_timeZone);
TimeUnit tu = m_sampling.getUnit();
switch (tu)
{
case YEARS:
dt = dt.withDayOfYear(1).withMillisOfDay(0);
break;
case MONTHS:
dt = dt.withDayOfMonth(1).withMillisOfDay(0);
break;
case WEEKS:
dt = dt.withDayOfWeek(1).withMillisOfDay(0);
break;
case DAYS:
case HOURS:
case MINUTES:
case SECONDS:
dt = dt.withHourOfDay(0);
dt = dt.withMinuteOfHour(0);
dt = dt.withSecondOfMinute(0);
default:
dt = dt.withMillisOfSecond(0);
break;
}
return dt.getMillis();
}
示例2: getDuration
import org.joda.time.DateTime; //導入方法依賴的package包/類
@Override
public int getDuration(DateTime now, DateTime expiryDate)
{
Interval interval = new Interval(now.withMillisOfSecond(0), expiryDate);
return interval.toPeriod(PeriodType.minutes()).getMinutes();
}