List of usage examples for org.joda.time DateTime toLocalDate
public LocalDate toLocalDate()
LocalDate
with the same date and chronology. From source file:org.zkoss.ganttz.TaskComponent.java
License:Open Source License
void doUpdateSize(int size) { DateTime end = new DateTime(this.task.getBeginDate().toDayRoundedDate().getTime()) .plus(getMapper().toDuration(size)); this.task.resizeTo(end.toLocalDate()); updateProperties();//www. j ava2 s . co m }
From source file:org.zkoss.ganttz.util.Interval.java
License:Open Source License
public Fraction getProportion(DateTime date) { Days fromStartToDate = Days.daysBetween(startInclusive, date.toLocalDate()); Fraction result = Fraction.getFraction(fromStartToDate.getDays(), this.daysBetween.getDays()); try {// w w w.j a v a 2 s.co m return result.add(inTheDayIncrement(date)); } catch (ArithmeticException e) { return result; } }
From source file:org.zkoss.ganttz.util.Interval.java
License:Open Source License
private Fraction inTheDayIncrement(DateTime date) { DateTime atStartOfDay = date.toLocalDate().toDateTimeAtStartOfDay(); Duration duration = new Duration(atStartOfDay, date); double result = ((double) duration.getMillis()) / lengthBetween.getMillis(); return Fraction.getFraction(result); }
From source file:pt.ist.expenditureTrackingSystem.domain.organization.UnitActiveResponsibleGroup.java
License:Open Source License
@Override public Stream<User> getMembers(final DateTime when) { final LocalDate localDate = when.toLocalDate(); return ExpenditureTrackingSystem.getInstance().getAuthorizationsSet().stream() .filter(a -> a.isValidFor(localDate) && isExpectedUnitType(a.getUnit())) .map(a -> a.getPerson().getUser()).distinct(); }
From source file:pt.ist.expenditureTrackingSystem.domain.organization.UnitActiveResponsibleGroup.java
License:Open Source License
@Override public boolean isMember(final User user, final DateTime when) { final Person person = user.getExpenditurePerson(); if (person != null) { final LocalDate localDate = when.toLocalDate(); for (final Authorization authorization : person.getAuthorizationsSet()) { if (authorization.isValidFor(localDate) && isExpectedUnitType(authorization.getUnit())) { return true; }/*w ww . j a va 2s .co m*/ } } return false; }
From source file:rabbit.data.internal.xml.store.AbstractStorer.java
License:Apache License
@Override public void insert(E event) { DateTime time = event.getTime(); if (!isSameMonthInYear(event.getTime(), currentMonth)) { commit();/*from ww w . j a va 2 s . co m*/ currentMonth = time.toLocalDate(); } IMerger<T> merger = getMerger(); T element = getConverter().convert(event); for (S category : data) { if (isSameDate(event.getTime(), category.getDate())) { if (merger != null) Mergers.merge(merger, getElements(category), element); else getElements(category).add(element); return; } } S category = newCategory(toXmlDate(event.getTime())); getElements(category).add(element); data.add(category); }
From source file:ui.main.MainViewController.java
private void loadChat(String chatterName) { if (chatterName.contains("/")) { chatterName = chatterName.substring(0, chatterName.indexOf("/")); //removing the requester's service }//from w ww. j a v a 2 s . com ResultSet rs = DBSingleChat.readMessages(chatterName); //load old messages //display old messages -> current chat is required to be set as a prerequisit String messageContent; boolean isRecieved; String type; Timestamp time; DateTime pre = null; DateTime cur; try { if (rs == null) { return; } while (rs.next()) { messageContent = rs.getString("messagecontent"); isRecieved = rs.getBoolean("sent"); type = rs.getString("type"); //time of each message time = rs.getTimestamp("time_"); cur = new DateTime(time.getTime()); if (null == pre) { pre = cur; paintDate(currentChat, dtf.print(cur)); } else if (pre.toLocalDate().compareTo(cur.toLocalDate()) != 0) { //creates a new date to print pre = cur; paintDate(currentChat, dtf.print(cur)); } if (type.equals("T")) { if (isRecieved) { paintReceivedMessage(currentChat, messageContent, dtfT.print(cur)); } else { paintSendMessage(messageContent, dtfT.print(cur)); } } else if (type.equals("P")) { if (isRecieved) { File file = new File(messageContent); if (!file.exists()) { paintWarningInRecieve(currentChat, "Photo Cannot be Loaded!", dtfT.print(cur)); } else { paintReceivedPhotoLoad(currentChat, file, dtfT.print(cur)); } } else { File file = new File(messageContent); if (!file.exists()) { paintWarningInRecieve(currentChat, "Photo Cannot be Loaded!", dtfT.print(cur)); } else { paintSentPhoto(currentChat, file, dtfT.print(cur)); } } } else if (type.equals("F")) { if (isRecieved) { File file = new File(messageContent); if (!file.exists()) { paintWarningInRecieve(currentChat, "File (" + messageContent + ") does not exist!", dtfT.print(cur)); } else { paintReceivedFile(currentChat, messageContent, dtfT.print(cur)); } } else { File file = new File(messageContent); if (!file.exists()) { paintWarningInRecieve(currentChat, "File (" + messageContent + ") does not exist!", dtfT.print(cur)); } else { paintReceivedFile(currentChat, messageContent, dtfT.print(cur)); } paintSentFile(currentChat, file.getPath(), dtfT.print(cur)); } } } if (null == pre) { pre = new DateTime(System.currentTimeMillis()); paintDate(currentChat, dtf.print(pre)); } else if (pre.toLocalDate().compareTo((new DateTime(System.currentTimeMillis())).toLocalDate()) != 0) { pre = new DateTime(System.currentTimeMillis()); paintDate(currentChat, dtf.print(pre)); } } catch (SQLException ex) { Logger.getLogger(MainViewController.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:uk.ac.cam.db538.cryptosms.ui.UtilsTextFormat.java
License:Apache License
/** * Format date time./*from w ww . j a va2s . co m*/ * * @param timeStamp the time stamp * @return the string */ public static String formatDateTime(DateTime timeStamp) { DateTime now = DateTime.now(); if (timeStamp.toLocalDate().equals(now.toLocalDate())) // today => just time return timeStamp.toString(DateTimeFormat.shortTime()); else // not today => just date return timeStamp.toString(DateTimeFormat.shortDate()); }