Tabnine Logo
SunshineDateUtils
Code IndexAdd Tabnine to your IDE (free)

How to use
SunshineDateUtils
in
com.example.android.sunshine.utilities

Best Java code snippets using com.example.android.sunshine.utilities.SunshineDateUtils (Showing top 20 results out of 900)

origin: udacity/ud851-Sunshine

  /**
   * Returns just the selection part of the weather query from a normalized today value.
   * This is used to get a weather forecast from today's date. To make this easy to use
   * in compound selection, we embed today's date as an argument in the query.
   *
   * @return The selection part of the weather query for today onwards
   */
  public static String getSqlSelectForTodayOnwards() {
    long normalizedUtcNow = SunshineDateUtils.normalizeDate(System.currentTimeMillis());
    return WeatherContract.WeatherEntry.COLUMN_DATE + " >= " + normalizedUtcNow;
  }
}
origin: udacity/ud851-Sunshine

long localDate = getLocalDateFromUTC(dateInMillis);
long dayNumber = getDayNumber(localDate);
long currentDayNumber = getDayNumber(System.currentTimeMillis());
  String dayName = getDayName(context, localDate);
  String readableDate = getReadableDateString(context, localDate);
  if (dayNumber - currentDayNumber < 2) {
  return getDayName(context, localDate);
} else {
  int flags = DateUtils.FORMAT_SHOW_DATE
origin: udacity/ud851-Sunshine

long daysFromEpochToProvidedDate = elapsedDaysSinceEpoch(dateInMillis);
long daysFromEpochToToday = elapsedDaysSinceEpoch(System.currentTimeMillis());
origin: udacity/ud851-Sunshine

long localDate = getLocalMidnightFromNormalizedUtcDate(normalizedUtcMidnight);
long daysFromEpochToProvidedDate = elapsedDaysSinceEpoch(localDate);
long daysFromEpochToToday = elapsedDaysSinceEpoch(System.currentTimeMillis());
  String dayName = getDayName(context, localDate);
  String readableDate = getReadableDateString(context, localDate);
  if (daysFromEpochToProvidedDate - daysFromEpochToToday < 2) {
  return getDayName(context, localDate);
} else {
  int flags = DateUtils.FORMAT_SHOW_DATE
origin: udacity/ud851-Sunshine

long startDay = SunshineDateUtils.getNormalizedUtcDateForToday();
  date = SunshineDateUtils.getFriendlyDateString(context, dateTimeMillis, false);
origin: udacity/ud851-Sunshine

String dateString = SunshineDateUtils.getFriendlyDateString(mContext, dateInMillis, false);
origin: udacity/ud851-Sunshine

  /**
   * Given a day, returns just the name to use for that day.
   *   E.g "today", "tomorrow", "Wednesday".
   *
   * @param context      Context to use for resource localization
   * @param dateInMillis The date in milliseconds (local time)
   *
   * @return the string day of the week
   */
  private static String getDayName(Context context, long dateInMillis) {
    /*
     * If the date is today, return the localized version of "Today" instead of the actual
     * day name.
     */
    long dayNumber = getDayNumber(dateInMillis);
    long currentDayNumber = getDayNumber(System.currentTimeMillis());
    if (dayNumber == currentDayNumber) {
      return context.getString(R.string.today);
    } else if (dayNumber == currentDayNumber + 1) {
      return context.getString(R.string.tomorrow);
    } else {
      /*
       * Otherwise, if the day is not today, the format is just the day of the week
       * (e.g "Wednesday")
       */
      SimpleDateFormat dayFormat = new SimpleDateFormat("EEEE");
      return dayFormat.format(dateInMillis);
    }
  }
}
origin: udacity/ud851-Sunshine

long localDate = getLocalMidnightFromNormalizedUtcDate(normalizedUtcMidnight);
long daysFromEpochToProvidedDate = elapsedDaysSinceEpoch(localDate);
long daysFromEpochToToday = elapsedDaysSinceEpoch(System.currentTimeMillis());
  String dayName = getDayName(context, localDate);
  String readableDate = getReadableDateString(context, localDate);
  if (daysFromEpochToProvidedDate - daysFromEpochToToday < 2) {
  return getDayName(context, localDate);
} else {
  int flags = DateUtils.FORMAT_SHOW_DATE
origin: udacity/ud851-Sunshine

long startDay = SunshineDateUtils.getNormalizedUtcDateForToday();
  date = SunshineDateUtils.getFriendlyDateString(context, dateTimeMillis, false);
origin: udacity/ud851-Sunshine

String dateString = SunshineDateUtils.getFriendlyDateString(mContext, dateInMillis, false);
origin: udacity/ud851-Sunshine

  /**
   * Given a day, returns just the name to use for that day.
   *   E.g "today", "tomorrow", "Wednesday".
   *
   * @param context      Context to use for resource localization
   * @param dateInMillis The date in milliseconds (local time)
   *
   * @return the string day of the week
   */
  private static String getDayName(Context context, long dateInMillis) {
    /*
     * If the date is today, return the localized version of "Today" instead of the actual
     * day name.
     */
    long dayNumber = getDayNumber(dateInMillis);
    long currentDayNumber = getDayNumber(System.currentTimeMillis());
    if (dayNumber == currentDayNumber) {
      return context.getString(R.string.today);
    } else if (dayNumber == currentDayNumber + 1) {
      return context.getString(R.string.tomorrow);
    } else {
      /*
       * Otherwise, if the day is not today, the format is just the day of the week
       * (e.g "Wednesday")
       */
      SimpleDateFormat dayFormat = new SimpleDateFormat("EEEE");
      return dayFormat.format(dateInMillis);
    }
  }
}
origin: udacity/ud851-Sunshine

long localDate = getLocalMidnightFromNormalizedUtcDate(normalizedUtcMidnight);
long daysFromEpochToProvidedDate = elapsedDaysSinceEpoch(localDate);
long daysFromEpochToToday = elapsedDaysSinceEpoch(System.currentTimeMillis());
  String dayName = getDayName(context, localDate);
  String readableDate = getReadableDateString(context, localDate);
  if (daysFromEpochToProvidedDate - daysFromEpochToToday < 2) {
  return getDayName(context, localDate);
} else {
  int flags = DateUtils.FORMAT_SHOW_DATE
origin: udacity/ud851-Sunshine

long localDate = getLocalDateFromUTC(dateInMillis);
long dayNumber = getDayNumber(localDate);
long currentDayNumber = getDayNumber(System.currentTimeMillis());
  String dayName = getDayName(context, localDate);
  String readableDate = getReadableDateString(context, localDate);
  if (dayNumber - currentDayNumber < 2) {
  return getDayName(context, localDate);
} else {
  int flags = DateUtils.FORMAT_SHOW_DATE
origin: udacity/ud851-Sunshine

long startDay = SunshineDateUtils.getNormalizedUtcDateForToday();
  date = SunshineDateUtils.getFriendlyDateString(context, dateTimeMillis, false);
origin: udacity/ud851-Sunshine

  /**
   * Returns just the selection part of the weather query from a normalized today value.
   * This is used to get a weather forecast from today's date. To make this easy to use
   * in compound selection, we embed today's date as an argument in the query.
   *
   * @return The selection part of the weather query for today onwards
   */
  public static String getSqlSelectForTodayOnwards() {
    long normalizedUtcNow = SunshineDateUtils.normalizeDate(System.currentTimeMillis());
    return WeatherContract.WeatherEntry.COLUMN_DATE + " >= " + normalizedUtcNow;
  }
}
origin: udacity/ud851-Sunshine

String dateString = SunshineDateUtils.getFriendlyDateString(mContext, dateInMillis, false);
origin: udacity/ud851-Sunshine

long daysFromEpochToProvidedDate = elapsedDaysSinceEpoch(dateInMillis);
long daysFromEpochToToday = elapsedDaysSinceEpoch(System.currentTimeMillis());
origin: udacity/ud851-Sunshine

  /**
   * Given a day, returns just the name to use for that day.
   *   E.g "today", "tomorrow", "Wednesday".
   *
   * @param context      Context to use for resource localization
   * @param dateInMillis The date in milliseconds (local time)
   *
   * @return the string day of the week
   */
  private static String getDayName(Context context, long dateInMillis) {
    /*
     * If the date is today, return the localized version of "Today" instead of the actual
     * day name.
     */
    long dayNumber = getDayNumber(dateInMillis);
    long currentDayNumber = getDayNumber(System.currentTimeMillis());
    if (dayNumber == currentDayNumber) {
      return context.getString(R.string.today);
    } else if (dayNumber == currentDayNumber + 1) {
      return context.getString(R.string.tomorrow);
    } else {
      /*
       * Otherwise, if the day is not today, the format is just the day of the week
       * (e.g "Wednesday")
       */
      SimpleDateFormat dayFormat = new SimpleDateFormat("EEEE");
      return dayFormat.format(dateInMillis);
    }
  }
}
origin: udacity/ud851-Sunshine

long localDate = getLocalMidnightFromNormalizedUtcDate(normalizedUtcMidnight);
long daysFromEpochToProvidedDate = elapsedDaysSinceEpoch(localDate);
long daysFromEpochToToday = elapsedDaysSinceEpoch(System.currentTimeMillis());
  String dayName = getDayName(context, localDate);
  String readableDate = getReadableDateString(context, localDate);
  if (daysFromEpochToProvidedDate - daysFromEpochToToday < 2) {
  return getDayName(context, localDate);
} else {
  int flags = DateUtils.FORMAT_SHOW_DATE
origin: udacity/ud851-Sunshine

long localDate = getLocalDateFromUTC(dateInMillis);
long dayNumber = getDayNumber(localDate);
long currentDayNumber = getDayNumber(System.currentTimeMillis());
  String dayName = getDayName(context, localDate);
  String readableDate = getReadableDateString(context, localDate);
  if (dayNumber - currentDayNumber < 2) {
  return getDayName(context, localDate);
} else {
  int flags = DateUtils.FORMAT_SHOW_DATE
com.example.android.sunshine.utilitiesSunshineDateUtils

Javadoc

Class for handling date conversions that are useful for Sunshine.

Most used methods

  • normalizeDate
    Normalizes a date (in milliseconds). Normalize, in our usage within Sunshine means to convert a give
  • getDayName
    Given a day, returns just the name to use for that day. E.g "today", "tomorrow", "Wednesday".
  • getFriendlyDateString
    Helper method to convert the database representation of the date into something to display to users.
  • getReadableDateString
    Returns a date string in the format specified, which shows an abbreviated date without a year.
  • elapsedDaysSinceEpoch
    This method returns the number of days since the epoch (January 01, 1970, 12:00 Midnight UTC) in UTC
  • getLocalMidnightFromNormalizedUtcDate
    This method will return the local time midnight for the provided normalized UTC date.
  • getNormalizedUtcDateForToday
    This method returns the number of milliseconds (UTC time) for today's date at midnight in the local
  • getDayNumber
    This method returns the number of days since the epoch (January 01, 1970, 12:00 Midnight UTC) in UTC
  • getLocalDateFromUTC
    Since all dates from the database are in UTC, we must convert the given date (in UTC timezone) to th
  • getUTCDateFromLocal
    Since all dates from the database are in UTC, we must convert the local date to the date in UTC time
  • isDateNormalized
    In order to ensure consistent inserts into WeatherProvider, we check that dates have been normalized
  • isDateNormalized

Popular in Java

  • Finding current android device location
  • scheduleAtFixedRate (Timer)
  • getSupportFragmentManager (FragmentActivity)
  • runOnUiThread (Activity)
  • BufferedInputStream (java.io)
    A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the i
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • Time (java.sql)
    Java representation of an SQL TIME value. Provides utilities to format and parse the time's represen
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • SSLHandshakeException (javax.net.ssl)
    The exception that is thrown when a handshake could not be completed successfully.
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now