List of usage examples for org.joda.time DateTimeUtils currentTimeMillis
public static final long currentTimeMillis()
From source file:azkaban.monitor.model.ExecutionModelImpl.java
License:Apache License
public synchronized List<WorkflowExecutionModel> getCompletedWorkflowModels(boolean reverseTime) { return getCompletedWorkflowModels(DateTimeUtils.currentTimeMillis(), reverseTime); }
From source file:azkaban.monitor.model.ExecutionModelImpl.java
License:Apache License
public synchronized void clearCompletedWorkflows() { clearCompletedWorkflows(DateTimeUtils.currentTimeMillis()); }
From source file:ch.cern.db.flume.sink.elasticsearch.TimestampedEvent.java
License:Apache License
TimestampedEvent(Event base) { setBody(base.getBody());// ww w .jav a 2 s. c o m Map<String, String> headers = Maps.newHashMap(base.getHeaders()); String timestampString = headers.get("timestamp"); if (StringUtils.isBlank(timestampString)) { timestampString = headers.get("@timestamp"); } if (StringUtils.isBlank(timestampString)) { this.timestamp = DateTimeUtils.currentTimeMillis(); headers.put("timestamp", String.valueOf(timestamp)); } else { this.timestamp = Long.valueOf(timestampString); } setHeaders(headers); }
From source file:ch.corten.aha.widget.DigitalClock.java
License:Apache License
private void updateClock() { setText(mDateFormat.print(DateTimeUtils.currentTimeMillis())); invalidate(); }
From source file:ch.corten.aha.worldclock.TimeZoneInfo.java
License:Open Source License
public static int getTimeDifference(DateTimeZone tz) { int milliseconds = tz.getOffset(DateTimeUtils.currentTimeMillis()); return milliseconds / 60000; }
From source file:ch.corten.aha.worldclock.WeatherWidget.java
License:Open Source License
public static void updateItemView(Context context, Cursor cursor, RemoteViews rv, DateFormat timeFormat) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); boolean customColors = prefs.getBoolean(context.getString(R.string.use_custom_colors_key), false); rv.setTextViewText(R.id.city_text, cursor.getString(cursor.getColumnIndex(Clocks.CITY))); String id = cursor.getString(cursor.getColumnIndex(Clocks.TIMEZONE_ID)); long now = DateTimeUtils.currentTimeMillis(); DateTimeZone tz = DateTimeZone.forID(id); if (SANS_JELLY_BEAN_MR1) { rv.setTextViewText(R.id.time_text, TimeZoneInfo.showTimeWithOptionalWeekDay(tz, now, timeFormat)); } else {/*www . j a va 2 s . co m*/ TimeZone javaTimeZone = TimeZoneInfo.convertToJavaTimeZone(tz, now); RemoteViewUtil.setTextClockTimeZone(rv, R.id.time_text, javaTimeZone.getID()); rv.setTextViewText(R.id.weekday_text, TimeZoneInfo.showDifferentWeekday(tz, now)); } rv.setTextViewText(R.id.condition_text, cursor.getString(cursor.getColumnIndex(Clocks.WEATHER_CONDITION))); String temperature = BindHelper.getTemperature(context, cursor, false); rv.setTextViewText(R.id.temp_text, temperature); int condCode = cursor.getInt(cursor.getColumnIndex(Clocks.CONDITION_CODE)); double lat = cursor.getDouble(cursor.getColumnIndex(Clocks.LATITUDE)); double lon = cursor.getDouble(cursor.getColumnIndex(Clocks.LONGITUDE)); if (!customColors) { rv.setImageViewResource(R.id.condition_image, WeatherIcons.getIcon(condCode, lon, lat)); } if (customColors) { int color = prefs.getInt(context.getString(R.string.background_color_key), Color.BLACK); RemoteViewUtil.setBackgroundColor(rv, R.id.widget_item, color); int foreground = prefs.getInt(context.getString(R.string.foreground_color_key), Color.WHITE); rv.setTextColor(R.id.city_text, foreground); rv.setTextColor(R.id.time_text, foreground); rv.setTextColor(R.id.condition_text, foreground); rv.setTextColor(R.id.temp_text, foreground); if (!SANS_JELLY_BEAN_MR1) { rv.setTextColor(R.id.weekday_text, foreground); } int res = WeatherIcons.getIcon(condCode, lon, lat); if (foreground != Color.WHITE) { Drawable drawable = context.getResources().getDrawable(res); Bitmap bmp = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Config.ARGB_8888); drawable.setColorFilter(foreground, Mode.MULTIPLY); Canvas canvas = new Canvas(bmp); drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); drawable.draw(canvas); drawable.setColorFilter(null); rv.setImageViewBitmap(R.id.condition_image, bmp); } else { rv.setImageViewResource(R.id.condition_image, WeatherIcons.getIcon(condCode, lon, lat)); } } else { RemoteViewUtil.setBackground(rv, R.id.widget_item, R.drawable.appwidget_dark_bg); int defaultColor = 0xffbebebe; rv.setTextColor(R.id.city_text, Color.WHITE); rv.setTextColor(R.id.time_text, defaultColor); rv.setTextColor(R.id.condition_text, defaultColor); rv.setTextColor(R.id.temp_text, Color.WHITE); if (!SANS_JELLY_BEAN_MR1) { rv.setTextColor(R.id.weekday_text, defaultColor); } } }
From source file:ch.corten.aha.worldclock.WorldClockWidgetProvider.java
License:Open Source License
private static void updateViews(Context context, RemoteViews views) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); boolean autoSort = prefs.getBoolean(context.getString(R.string.auto_sort_clocks_key), true); Cursor cursor = Clocks.widgetList(context, PROJECTION, autoSort); try {/*from w w w.j av a 2 s . c om*/ int n = 0; DateFormat df = android.text.format.DateFormat.getTimeFormat(context); long now = DateTimeUtils.currentTimeMillis(); final int maxEntries = context.getResources().getInteger(R.integer.worldclock_widget_max_entries); while (cursor.moveToNext() && n < CITY_IDS.length && n < maxEntries) { String id = cursor.getString(cursor.getColumnIndex(Clocks.TIMEZONE_ID)); String city = cursor.getString(cursor.getColumnIndex(Clocks.CITY)); views.setTextViewText(CITY_IDS[n], city); DateTimeZone tz = DateTimeZone.forID(id); if (SANS_JELLY_BEAN_MR1) { views.setTextViewText(TIME_IDS[n], TimeZoneInfo.formatDate(df, tz, now)); } else { TimeZone javaTimeZone = TimeZoneInfo.convertToJavaTimeZone(tz, now); views.setViewVisibility(TIME_IDS[n], View.VISIBLE); RemoteViewUtil.setTextClockTimeZone(views, TIME_IDS[n], javaTimeZone.getID()); } n++; } int showEmptyText = (n == 0) ? View.VISIBLE : View.INVISIBLE; views.setViewVisibility(R.id.empty_text, showEmptyText); for (; n < CITY_IDS.length; n++) { views.setTextViewText(CITY_IDS[n], ""); if (SANS_JELLY_BEAN_MR1) { views.setTextViewText(TIME_IDS[n], ""); } else { views.setViewVisibility(TIME_IDS[n], View.INVISIBLE); } } boolean customColors = prefs.getBoolean(context.getString(R.string.use_custom_colors_key), false); int textColor = Color.WHITE; if (customColors) { int color = prefs.getInt(context.getString(R.string.background_color_key), Color.BLACK); RemoteViewUtil.setBackgroundColor(views, R.id.app_widget, color); textColor = prefs.getInt(context.getString(R.string.foreground_color_key), Color.WHITE); } else { RemoteViewUtil.setBackground(views, R.id.app_widget, R.drawable.appwidget_dark_bg); } for (int i = 0; i < CITY_IDS.length; i++) { views.setTextColor(CITY_IDS[i], textColor); views.setTextColor(TIME_IDS[i], textColor); } } finally { if (cursor != null) { cursor.close(); } } }
From source file:com.clicktravel.cheddar.server.application.lifecycle.ApplicationLifecycleController.java
License:Apache License
public synchronized void shutdownApplication() { if (!shutdownRequested) { shutdownRequested = true;/*from ww w .j a v a2 s . c om*/ logger.info("Shutting down application"); shutdownDeadline = DateTimeUtils.currentTimeMillis() + SHUTDOWN_TIMEOUT_MILLIS; messageListeners.stream().forEach(MessageListener::prepareForShutdown); restServer.shutdownAndAwait(millisToShutdownDeadline()); logger.info("Shutting down message listeners (except system message listener)"); shutdownAndAwait(messageListenersExcept(systemEventMessageListener)); logger.info("Shutting down system event message listener"); shutdownAndAwait(Collections.singleton(systemEventMessageListener)); logger.info("Application shutdown completed"); } else { logger.debug("Application already shut down"); } }
From source file:com.clicktravel.cheddar.server.application.lifecycle.ApplicationLifecycleController.java
License:Apache License
private long millisToShutdownDeadline() { return Math.max(0, shutdownDeadline - DateTimeUtils.currentTimeMillis()); }
From source file:com.DSC.client.SecureChannel.java
License:Open Source License
/** * Gets the date time offset for the client using a NTP server * @throws IOException /*from w w w . j a v a 2 s. c om*/ */ private static long getTimeOffset() throws IOException { NTPUDPClient timeClient = new NTPUDPClient(); InetAddress inetAddress = InetAddress.getByName(NTP_SERVER); TimeInfo timeInfo = timeClient.getTime(inetAddress); return DateTimeUtils.currentTimeMillis() - timeInfo.getReturnTime(); }