List of usage examples for org.joda.time DateMidnight DateMidnight
public DateMidnight()
ISOChronology
in the default time zone. From source file:net.naonedbus.appwidget.HoraireWidgetProvider.java
License:Open Source License
/** * Prparer le widget, le mettre jour si ncessaire. *//*from www . java 2 s.c o m*/ protected void prepareWidgetView(final Context context, final RemoteViews views, final Favori favori, final Integer appWidgetId) { if (DBG) Log.d(LOG_TAG, Integer.toHexString(hashCode()) + " - " + appWidgetId + " - prepareWidgetView " + favori); final HoraireManager horaireManager = HoraireManager.getInstance(); final DateMidnight today = new DateMidnight(); // Initialisation du widget prepareWidgetViewInit(context, views, favori); setOnClickListener(context, views, favori); try { if (horaireManager.isInDB(context.getContentResolver(), favori, today, mHoraireLimit)) { // Les horaires sont en cache final List<Horaire> horaires = horaireManager.getNextSchedules(context.getContentResolver(), favori, today, mHoraireLimit); prepareWidgetViewHoraires(context, views, favori, horaires); } else { // Charger les prochains horaires prepareWidgetAndloadHoraires(context, views, favori, appWidgetId); } } catch (final IOException e) { if (DBG) Log.e(LOG_TAG, Integer.toHexString(hashCode()) + " - " + appWidgetId + " - Erreur lors du chargement des horaires", e); } }
From source file:net.naonedbus.formatter.CommentaireFomatter.java
License:Open Source License
public CommentaireFomatter(final Context context) { this.mContext = context; mNow = new DateMidnight(); mYesterday = mNow.minusDays(1);/* ww w . ja v a 2 s . co m*/ mLigneManager = LigneManager.getInstance(); mSensManager = SensManager.getInstance(); mArretManager = ArretManager.getInstance(); }
From source file:net.naonedbus.fragment.impl.HorairesFragment.java
License:Open Source License
public HorairesFragment() { super(R.layout.fragment_listview_section); mHoraireManager = HoraireManager.getInstance(); mFavoriManager = FavoriManager.getInstance(); mArretManager = ArretManager.getInstance(); mSensManager = SensManager.getInstance(); mHoraires = new ArrayList<Horaire>(); mLastDayLoaded = new DateMidnight(); mDayToLoad = new DateMidnight(); }
From source file:net.naonedbus.fragment.impl.HorairesFragment.java
License:Open Source License
private void changeDateToNow() { changeDate(new DateMidnight()); }
From source file:net.naonedbus.manager.impl.HoraireManager.java
License:Open Source License
/** * Supprimer les horaires de plus d'1 jour. *//*from www. j a v a 2s. c om*/ public void clearOldSchedules(final ContentResolver contentResolver) { if (DBG) Log.i(LOG_TAG, "Nettoyage du cache horaires"); synchronized (mDatabaseLock) { contentResolver.delete(HoraireProvider.CONTENT_URI, HoraireTable.JOUR + " < ?", new String[] { String.valueOf(new DateMidnight().minusDays(1).getMillis()) }); } }
From source file:net.naonedbus.manager.impl.HoraireManager.java
License:Open Source License
/** * Rcuprer les horaires d'un arrt.//ww w.ja v a 2s. com * * @throws IOException */ public List<Horaire> getSchedules(final ContentResolver contentResolver, final Arret arret, final DateMidnight date, final DateTime after) throws IOException { // Le cache ne doit stocker que les horaires du jour et du lendemain. final DateMidnight cacheLimit = new DateMidnight().plusDays(DAYS_IN_CACHE); final DateMidnight today = new DateMidnight(); final DateTime now = new DateTime(); List<Horaire> horaires; if (date.isBefore(cacheLimit)) { final ScheduleToken todayToken = new ScheduleToken(date.getMillis(), arret.getId()); // Partie atomique synchronized (mDatabaseLock) { if (!isInDB(contentResolver, todayToken)) { // Charger les horaires depuis le web et les stocker en base if (date.isEqual(today) && now.getHourOfDay() < END_OF_TRIP_HOURS) { // Charger la veille si besoin (pour les horaires aprs // minuit) final ScheduleToken yesterdayToken = new ScheduleToken(date.minusDays(1).getMillis(), arret.getId()); if (isInDB(contentResolver, yesterdayToken)) { horaires = mController.getAllFromWeb(arret, date.minusDays(1)); fillDB(contentResolver, yesterdayToken, horaires); } } horaires = mController.getAllFromWeb(arret, date); fillDB(contentResolver, todayToken, horaires); } // Charger les horaires depuis la base final Uri.Builder builder = HoraireProvider.CONTENT_URI.buildUpon(); builder.path(HoraireProvider.HORAIRE_JOUR_URI_PATH_QUERY); builder.appendQueryParameter(HoraireProvider.PARAM_ARRET_ID, String.valueOf(arret.getId())); builder.appendQueryParameter(HoraireProvider.PARAM_JOUR, mIso8601Format.format(date.toDate())); builder.appendQueryParameter(HoraireProvider.PARAM_INCLUDE_LAST_DAY_TRIP, "true"); // Eviter l'affichage de doublons if (after != null) { builder.appendQueryParameter(HoraireProvider.PARAM_AFTER_TIME, mIso8601Format.format(after.toDate())); } final Cursor cursor = contentResolver.query(builder.build(), null, null, null, null); horaires = getFromCursor(cursor); cursor.close(); } } else { horaires = mController.getAllFromWeb(arret, date); } return horaires; }
From source file:net.naonedbus.manager.impl.HoraireManager.java
License:Open Source License
/** * Rcuprer le nombre de minutes jusqu'au prochain horaire. * //w ww . j ava 2 s.c o m * @throws IOException */ public Integer getMinutesToNextSchedule(final ContentResolver contentResolver, final Arret arret) throws IOException { final List<Horaire> nextSchedules = getNextSchedules(contentResolver, arret, new DateMidnight(), 1); Integer result = null; if (nextSchedules.size() > 0) { final Horaire next = nextSchedules.get(0); final DateTime itemDateTime = new DateTime(next.getHoraire()).withSecondOfMinute(0) .withMillisOfSecond(0); final DateTime now = new DateTime().withSecondOfMinute(0).withMillisOfSecond(0); result = Minutes.minutesBetween(now, itemDateTime).getMinutes(); } return result; }
From source file:net.sourceforge.atunes.kernel.modules.tags.JAudiotaggerTagCreator.java
License:Open Source License
/** * @param iTag/* w w w. ja v a 2 s . c om*/ * @param tag */ private void setDateFromID3v23Tag(final ITag iTag, final org.jaudiotagger.tag.Tag tag) { // Set date from fields tag TYER and date/month tag TDAT DateMidnight c = null; String yearPart = getFirstTagValue(tag, "TYER"); if (!StringUtils.isEmpty(yearPart)) { try { c = new DateMidnight().withYear(Integer.parseInt(yearPart)).withMonthOfYear(1).withDayOfMonth(1); String dateMonthPart = getFirstTagValue(tag, "TDAT"); if (!StringUtils.isEmpty(dateMonthPart) && dateMonthPart.length() >= 4) { c = c.withMonthOfYear(Integer.parseInt(dateMonthPart.substring(2, 4))) .withDayOfMonth(Integer.parseInt(dateMonthPart.substring(0, 2))); } } catch (NumberFormatException e) { // Skip this date } catch (IllegalArgumentException e) { // Skip this date } } if (c != null) { iTag.setDate(c); } }
From source file:net.sourceforge.fenixedu.domain.Attends.java
License:Open Source License
public Interval getPreviousWeek() { final DateMidnight thisMonday = new DateMidnight().withField(DateTimeFieldType.dayOfWeek(), 1); final DateMidnight previousMonday = thisMonday.minusWeeks(1); return new Interval(previousMonday, thisMonday); }
From source file:net.sourceforge.fenixedu.domain.ExecutionSemester.java
License:Open Source License
public DateMidnight getThisMonday() { final DateTime beginningOfSemester = getBeginDateYearMonthDay().toDateTimeAtMidnight(); final DateTime endOfSemester = getEndDateYearMonthDay().toDateTimeAtMidnight(); if (beginningOfSemester.isAfterNow() || endOfSemester.isBeforeNow()) { return null; }/*from w w w. ja va2s.c om*/ final DateMidnight now = new DateMidnight(); return now.withField(DateTimeFieldType.dayOfWeek(), 1); }