List of usage examples for org.joda.time DateTimeZone forTimeZone
public static DateTimeZone forTimeZone(TimeZone zone)
From source file:org.projectforge.framework.persistence.user.api.ThreadLocalUserContext.java
License:Open Source License
public final static DateTimeZone getDateTimeZone() { final TimeZone timeZone = getTimeZone(); return DateTimeZone.forTimeZone(timeZone); }
From source file:org.sakaiproject.tool.summarycalendar.ui.CalendarBean.java
License:Educational Community License
private CalendarEventVector getScheduleEventsForDay(Calendar c) { CalendarEventVector cev = new CalendarEventVector(); TimeZone timeZone = getCurrentUserTimezone(); DateTime start = new DateTime(c).withZone(DateTimeZone.forTimeZone(timeZone)).withTime(0, 0, 0, 0); LOG.debug("looking for events for: " + start); Time sod = M_ts.newTime(start.getMillis()); DateTime endOfDay = new DateTime(c).withZone(DateTimeZone.forTimeZone(timeZone)).withTime(23, 59, 59, 0); Time eod = M_ts.newTime(endOfDay.getMillis()); TimeRange range = M_ts.newTimeRange(sod, eod); Iterator<CalendarEvent> i = getEventsFromSchedule().iterator(); while (i.hasNext()) { CalendarEvent ce = (CalendarEvent) i.next(); TimeRange tr = ce.getRange();/*from ww w. j ava 2 s. c o m*/ if (range.contains(tr.firstTime()) || range.contains(tr.lastTime())) { LOG.debug("found event: " + ce.getDisplayName()); cev.add(ce); } } return cev; }
From source file:org.sakaiproject.tool.summarycalendar.ui.EventSummary.java
License:Educational Community License
private boolean isToday(long dateMs) { TimeZone timeZone = getCurrentUserTimezone(); DateTime thisDate = new DateTime(dateMs).withZone(DateTimeZone.forTimeZone(timeZone)); //Start of day at this local DateTime today = new DateTime().withTime(0, 0, 0, 0).withZone(DateTimeZone.forTimeZone(timeZone)); DateTimeComparator dtComp = DateTimeComparator.getDateOnlyInstance(); return (dtComp.compare(thisDate, today) == 0); }
From source file:org.sleuthkit.autopsy.timeline.TimeLineController.java
License:Open Source License
public static DateTimeZone getJodaTimeZone() { return DateTimeZone.forTimeZone(getTimeZone().get()); }
From source file:org.solovyev.android.messenger.messages.MessageImpl.java
License:Apache License
@Nonnull @Override/* w w w . j a v a2s . com*/ public DateTime getLocalSendDateTime() { if (localSendDateTime == null) { final DateTimeZone localTimeZone = DateTimeZone.forTimeZone(TimeZone.getDefault()); localSendDateTime = sendDate.toDateTime(localTimeZone); } return localSendDateTime; }
From source file:org.solovyev.android.messenger.messages.Messages.java
License:Apache License
@Nonnull public static CharSequence getMessageTime(@Nonnull Message message) { final DateTimeZone localTimeZone = DateTimeZone.forTimeZone(TimeZone.getDefault()); final DateTime localSendDateTime = message.getLocalSendDateTime(); final LocalDate localSendDate = message.getLocalSendDate(); final LocalDate localToday = now(localTimeZone).toLocalDate(); final LocalDate localYesterday = localToday.minusDays(1); if (localSendDate.toDateTimeAtStartOfDay().compareTo(localToday.toDateTimeAtStartOfDay()) == 0) { // today/*from w w w.ja v a 2s . c o m*/ // print time return shortTime().print(localSendDateTime); } else if (localSendDate.toDateTimeAtStartOfDay().compareTo(localYesterday.toDateTimeAtStartOfDay()) == 0) { // yesterday return getApplication().getString(R.string.mpp_yesterday_at) + " " + shortTime().print(localSendDateTime); } else { // the days before yesterday return shortDate().print(localSendDateTime) + " " + getApplication().getString(R.string.mpp_at_time) + " " + shortTime().print(localSendDateTime); } }
From source file:org.solovyev.android.messenger.messages.MessagesMock.java
License:Apache License
@Nonnull public static Message newMockMessage(@Nonnull DateTime sendDate, @Nonnull Entity from, @Nonnull Entity to, @Nonnull String accountId, @Nonnull String chatId) { final Message message = mock(Message.class); final String id = getMessageId(); when(message.getEntity()).thenReturn(newEntity(accountId, id)); when(message.getId()).thenReturn(String.valueOf(id)); when(message.getBody()).thenReturn("body_" + id); when(message.getTitle()).thenReturn("title_" + id); when(message.getAuthor()).thenReturn(from); when(message.getRecipient()).thenReturn(to); when(message.getState()).thenReturn(created); when(message.getSendDate()).thenReturn(sendDate); final DateTime localDateTime = sendDate.toDateTime(DateTimeZone.forTimeZone(TimeZone.getDefault())); when(message.getLocalSendDateTime()).thenReturn(localDateTime); when(message.getLocalSendDate()).thenReturn(localDateTime.toLocalDate()); final MutableAProperties properties = newProperties(Collections.<AProperty>emptyList()); properties.setProperty("property_1", "test"); properties.setProperty("property_2", "42"); when(message.getProperties()).thenReturn(properties); when(message.getChat()).thenReturn(newEntityFromEntityId(chatId)); return message; }
From source file:org.specrunner.converters.core.ConverterDateMidnightPatternArgs.java
License:Open Source License
@Override public Object convert(Object value, Object[] args) throws ConverterException { if (value == null) { return null; }/*from w w w . j a v a2s . com*/ if (value instanceof DateMidnight) { return value; } try { if (args.length < 1) { throw new ConverterException("Converter '" + getClass() + "' missing pattern argument information (i.e. arg0=\"dd/MM/yyyy\")."); } String pattern = String.valueOf(args[0]); synchronized (cache) { DateTimeFormatter formatter = cache.get(pattern); if (formatter == null) { formatter = DateTimeFormat.forPattern(pattern); cache.put(pattern, formatter); } TimeZone tz = getZone(); if (tz != null) { formatter = formatter.withZone(DateTimeZone.forTimeZone(tz)); } return formatter.parseDateTime(String.valueOf(value)).toDateMidnight(); } } catch (IllegalArgumentException e) { throw new ConverterException(e); } }
From source file:org.specrunner.converters.core.ConverterDateTimePatternArgs.java
License:Open Source License
@Override public Object convert(Object value, Object[] args) throws ConverterException { if (value == null) { return null; }//w ww . j a v a2 s .c om if (value instanceof DateTime) { return value; } try { if (args.length < 1) { throw new ConverterException("Converter '" + getClass() + "' missing pattern argument information (i.e. arg0=\"dd/MM/yyyy\")."); } String pattern = String.valueOf(args[0]); synchronized (cache) { DateTimeFormatter formatter = cache.get(pattern); if (formatter == null) { formatter = DateTimeFormat.forPattern(pattern); cache.put(pattern, formatter); } TimeZone tz = getZone(); if (tz != null) { formatter = formatter.withZone(DateTimeZone.forTimeZone(tz)); } return formatter.parseDateTime(String.valueOf(value)); } } catch (IllegalArgumentException e) { throw new ConverterException(e); } }
From source file:org.specrunner.converters.core.ConverterMutableDateTimePatternArgs.java
License:Open Source License
@Override public Object convert(Object value, Object[] args) throws ConverterException { if (value == null) { return null; }/*from w ww . j a va 2 s.c om*/ if (value instanceof DateTime) { return value; } try { if (args.length < 1) { throw new ConverterException("Converter '" + getClass() + "' missing pattern argument information (i.e. arg0=\"dd/MM/yyyy\")."); } String pattern = String.valueOf(args[0]); synchronized (cache) { DateTimeFormatter formatter = cache.get(pattern); if (formatter == null) { formatter = DateTimeFormat.forPattern(pattern); cache.put(pattern, formatter); } TimeZone tz = getZone(); if (tz != null) { formatter = formatter.withZone(DateTimeZone.forTimeZone(tz)); } return formatter.parseDateTime(String.valueOf(value)).toMutableDateTime(); } } catch (IllegalArgumentException e) { throw new ConverterException(e); } }