List of usage examples for org.joda.time DateTime withTimeAtStartOfDay
public DateTime withTimeAtStartOfDay()
From source file:org.openmainframe.ade.ext.utils.ExtDateTimeUtils.java
License:Open Source License
/** * Method to return a "normalized" version of the input Date * whose time is reset to the absolute start of that same day * (first millisecond of first second of first minute of first hour). * //from ww w .j a v a 2s . c o m * @param dateInst - instance of Date * @return - instance of Date as described * @throws AdeException */ public static Date startOfDayUsingOutputTimeZone(Date dateInst) throws AdeException { if (outputTimeZone == null) { final TimeZone outputTimezone = Ade.getAde().getConfigProperties().getOutputTimeZone(); outputTimeZone = DateTimeZone.forOffsetMillis(outputTimezone.getRawOffset()); } if (dateInst == null) { throw new IllegalArgumentException(); } /* Set start of today */ DateTime startOFDay = new DateTime(dateInst); startOFDay = startOFDay.withZone(outputTimeZone); startOFDay = startOFDay.withTimeAtStartOfDay(); return startOFDay.toDate(); }
From source file:org.openmainframe.ade.ext.utils.ExtDateTimeUtils.java
License:Open Source License
/** * Method to return a "normalized" version of the input Date * whose time is reset to the absolute start of that same day * (first millisecond of first second of first minute of first hour). * //from ww w. j a va 2s. c o m * @param dateInst - instance of Date * @return - instance of Date as described * @throws AdeException */ public static Date endOfDayUsingOutputTimeZone(Date dateInst) throws AdeException { /* * Note: This method generates a different end of day compare to endOfDay(). * endOfDay() would generate timestamp: 10/10/2013 23:59:59 * endOfDayUsingOutputTimeZone() would generate timestampe: 10/11/2013 00:00:00 */ if (outputTimeZone == null) { final TimeZone outputTimezone = Ade.getAde().getConfigProperties().getOutputTimeZone(); outputTimeZone = DateTimeZone.forOffsetMillis(outputTimezone.getRawOffset()); } if (dateInst == null) { throw new IllegalArgumentException(); } /* Set end of today */ DateTime startOFDay = new DateTime(dateInst); startOFDay = startOFDay.withZone(outputTimeZone); startOFDay = startOFDay.plusDays(1); startOFDay = startOFDay.withTimeAtStartOfDay(); return startOFDay.toDate(); }
From source file:org.projectbuendia.client.ui.chart.LocalizedChartDataGridAdapter.java
License:Apache License
private String toColumnId(DateTime dateTime) { int hour = dateTime.getHourOfDay() >= 12 ? 12 : 0; // choose am or pm column return dateTime.withTimeAtStartOfDay().withHourOfDay(hour).toString(); }
From source file:org.sakaiproject.util.CalendarUtil.java
License:Educational Community License
static String getLocalAMString(DateTime now) { //we need an AM date DateTime dt = now.withTimeAtStartOfDay(); Locale locale = new ResourceLoader("calendar").getLocale(); DateTimeFormatter df = new DateTimeFormatterBuilder().appendHalfdayOfDayText().toFormatter() .withLocale(locale);/* w w w .java 2 s . c om*/ return df.print(dt); }
From source file:org.sakaiproject.util.CalendarUtil.java
License:Educational Community License
static String getLocalPMString(DateTime now) { //we need an PM date DateTime dt = now.withTimeAtStartOfDay().plusHours(14); Locale locale = new ResourceLoader("calendar").getLocale(); DateTimeFormatter df = new DateTimeFormatterBuilder().appendHalfdayOfDayText().toFormatter() .withLocale(locale);//from w ww .java 2 s .com return df.print(dt); }
From source file:org.springframework.analytics.metrics.redis.RedisAggregateCounterRepository.java
License:Apache License
private long[] getDayCountsForMonth(String name, DateTime month) { AggregateKeyGenerator akg = new AggregateKeyGenerator(AGGREGATE_COUNTER_KEY_PREFIX, name, month.withTimeAtStartOfDay()); return convertToArray(getEntries(akg.getMonthKey()), month.dayOfMonth().getMaximumValue(), true); // Days in this month }
From source file:org.springframework.analytics.metrics.redis.RedisAggregateCounterRepository.java
License:Apache License
private long[] getHourCountsForDay(String name, DateTime day) { AggregateKeyGenerator akg = new AggregateKeyGenerator(AGGREGATE_COUNTER_KEY_PREFIX, name, day.withTimeAtStartOfDay()); return convertToArray(getEntries(akg.getDayKey()), 24, false); }
From source file:org.springframework.cloud.stream.app.metrics.redis.RedisAggregateCounterRepository.java
License:Apache License
private long[] getDayCountsForMonth(String name, DateTime month) { AggregateKeyGenerator akg = new AggregateKeyGenerator(REPO_PREFIX, name, month.withTimeAtStartOfDay()); return convertToArray(getEntries(akg.getMonthKey()), month.dayOfMonth().getMaximumValue(), true); // Days in this month }
From source file:org.springframework.cloud.stream.app.metrics.redis.RedisAggregateCounterRepository.java
License:Apache License
private long[] getHourCountsForDay(String name, DateTime day) { AggregateKeyGenerator akg = new AggregateKeyGenerator(REPO_PREFIX, name, day.withTimeAtStartOfDay()); return convertToArray(getEntries(akg.getDayKey()), 24, false); }
From source file:org.springframework.xd.analytics.metrics.redis.RedisAggregateCounterRepository.java
License:Apache License
private long[] getDayCountsForMonth(String name, DateTime month) { AggregateKeyGenerator akg = new AggregateKeyGenerator(getPrefix(), name, month.withTimeAtStartOfDay()); return convertToArray(getEntries(akg.getMonthKey()), month.dayOfMonth().getMaximumValue(), true); // Days in this month }