Example usage for android.text.format Time Time

List of usage examples for android.text.format Time Time

Introduction

In this page you can find the example usage for android.text.format Time Time.

Prototype

public Time() 

Source Link

Document

Construct a Time object in the default timezone.

Usage

From source file:com.osfans.trime.DictionaryHelper.java

static String getExportName() {
    Time t = new Time();
    t.setToNow();
    return String.format("trime_%s.db", t.format2445());
}

From source file:com.android.calendar.year.YearViewPagerFragment.java

public YearViewPagerFragment(long timeMillis) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTimeInMillis(timeMillis);
    Time gTime = new Time();
    gTime.set(timeMillis);/*from  ww  w .  j  a va2  s  .co m*/
    mCurrentJalaliYear = Jalali.gregorianToJalali(gTime).year;
    // check
    if (mCurrentJalaliYear < EPOCH_TIME_YEAR_START || mCurrentJalaliYear > EPOCH_TIME_YEAR_END) {
        mCurrentJalaliYear = EPOCH_TIME_YEAR_START;
    }
    // mCurrentMonth = calendar.get(Calendar.MONTH);
}

From source file:com.dgsd.android.ShiftTracker.Adapter.WeekAdapter.java

public WeekAdapter(Context context, Cursor c, int julianDay) {
    super(context, c, false);
    inflater = LayoutInflater.from(context);
    mStartingJulianDay = julianDay;// ww w .java2 s . co m
    mRand = new Random();
    mTime = new Time();

    mIs24Hour = DateFormat.is24HourFormat(context);

    mStringBuilder = new StringBuilder();
    mFormatter = new Formatter((mStringBuilder));

    mCurrencyFormatter = NumberFormat.getCurrencyInstance();

    //Caching
    mJdToTitleArray = new SparseArray<String>();
    mIdToTimeArray = new SparseArray<String>();
    mIdToPayArray = new SparseArray<String>();

    mCurrentJulianDay = TimeUtils.getCurrentJulianDay();

    mShowIncomePref = Prefs.getInstance(context).get(context.getString(R.string.settings_key_show_income),
            true);
}

From source file:pro.jariz.reisplanner.fragments.PlannerFragment.java

@Override
public void Invoke(Object Result, Integer TaskType) {

    if (Result == null) {
        //Result has returned null, which means somethings wrong.
        //Show feedback to user in form of a Crouton, using NSTask.LastExceptionMessage
        Crouton.showText(this.getActivity(), "Unable to update station list: " + NSTask.LastExceptionMessage,
                CroutonStyles.errorStyle);
        return;//from  w  ww .  j a v a 2  s .c om
    }

    Object[] stationso = (Object[]) Result;
    NSStation[] stations = Arrays.copyOf(stationso, stationso.length, NSStation[].class);

    if (TaskType == NSTask.TYPE_STATIONS) {
        //update cache time & clear & insert into db
        Time now = new Time();
        now.setToNow();
        DB.setLastCacheTime("stations", new BigDecimal(now.toMillis(true)).intValue());
        DB.clearStations();
        DB.insertStations(stations);

        Crouton.showText(this.getActivity(), getResources().getString(R.string.updating_station_list_done),
                CroutonStyles.successStyle);
    }

    Render(stations, thisView, this.getActivity());
}

From source file:eu.inmite.apps.smsjizdenka.adapter.TicketsAdapter.java

/**
 * Gets validity of ticket with time {@code t} in minutes.
 *//*from  w ww.j  a  v a  2s  . c  o  m*/
public static int getValidityMinutes(Time t) {
    if (t == null) {
        return -1;
    }

    final Time now = new Time();
    now.setToNow();
    now.switchTimezone(Time.getCurrentTimezone());
    return (int) Math.ceil((t.toMillis(true) - now.toMillis(true)) / 1000d / 60d);
}

From source file:es.android.TurnosAndroid.fragments.DayFragment.java

public DayFragment() {
    selectedDay = new Time();
}

From source file:com.ewintory.footballscores.ui.adapter.PagerAdapter.java

public String getDayName(Context context, long dateInMillis) {
    // If the date is today, return the localized version of "Today" instead of the actual
    // day name.//from  w  ww. j a va 2  s .c  om

    Time t = new Time();
    t.setToNow();
    int julianDay = Time.getJulianDay(dateInMillis, t.gmtoff);
    int currentJulianDay = Time.getJulianDay(System.currentTimeMillis(), t.gmtoff);
    if (julianDay == currentJulianDay) {
        return context.getString(R.string.today);
    } else if (julianDay == currentJulianDay + 1) {
        return context.getString(R.string.tomorrow);
    } else if (julianDay == currentJulianDay - 1) {
        return context.getString(R.string.yesterday);
    } else {
        Time time = new Time();
        time.setToNow();
        // Otherwise, the format is just the day of the week (e.g "Wednesday".
        return DAY_FORMAT.format(dateInMillis);
    }
}

From source file:edu.htl3r.schoolplanner.DateTimeUtils.java

public static Time toTime(DateTime dateTime) {
    Time time = new Time();
    time.set(dateTime.getSecond(), dateTime.getMinute(), dateTime.getHour(), dateTime.getDay(),
            dateTime.getMonth() - 1, dateTime.getYear());
    return time;//from w  w w.ja  va 2 s  . c o  m
}

From source file:com.dgsd.android.ShiftTracker.Fragment.HoursAndIncomeSummaryFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    View v = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_hour_and_income_summary, null);

    mMonth = (TextView) v.findViewById(R.id.month);
    mThreeMonth = (TextView) v.findViewById(R.id.three_months);
    mSixMonth = (TextView) v.findViewById(R.id.six_months);
    mNineMonth = (TextView) v.findViewById(R.id.nine_months);
    mThisYear = (TextView) v.findViewById(R.id.year);

    AlertDialog.Builder b = new AlertDialog.Builder(getActivity());
    b.setView(v);//w  w w .  j  a  va  2s  .  c om

    Time time = new Time();
    time.setJulianDay(mJulianDay);

    b.setTitle(DateFormat.getDateFormat(getActivity()).format(time.toMillis(true)));

    Dialog d = b.create();
    d.setCanceledOnTouchOutside(true);

    return d;
}

From source file:com.example.android.sunshine.app.Utility.java

/**
 * Helper method to convert the database representation of the date into something to display
 * to users.  As classy and polished a user experience as "20140102" is, we can do better.
 *
 * @param context Context to use for resource localization
 * @param dateInMillis The date in milliseconds
 * @return a user-friendly representation of the date.
 *///  www . j  a v a2s  .c  om
public static String getFriendlyDayString(Context context, long dateInMillis, boolean displayLongToday) {
    // The day string for forecast uses the following logic:
    // For today: "Today, June 8"
    // For tomorrow:  "Tomorrow"
    // For the next 5 days: "Wednesday" (just the day name)
    // For all days after that: "Mon Jun 8"

    Time time = new Time();
    time.setToNow();
    long currentTime = System.currentTimeMillis();
    int julianDay = Time.getJulianDay(dateInMillis, time.gmtoff);
    int currentJulianDay = Time.getJulianDay(currentTime, time.gmtoff);

    // If the date we're building the String for is today's date, the format
    // is "Today, June 24"
    if (displayLongToday && julianDay == currentJulianDay) {
        String today = context.getString(R.string.today);
        int formatId = R.string.format_full_friendly_date;
        return String.format(context.getString(formatId, today, getFormattedMonthDay(context, dateInMillis)));
    } else if (julianDay < currentJulianDay + 7) {
        // If the input date is less than a week in the future, just return the day name.
        return getDayName(context, dateInMillis);
    } else {
        // Otherwise, use the form "Mon Jun 3"
        SimpleDateFormat shortenedDateFormat = new SimpleDateFormat("EEE MMM dd");
        return shortenedDateFormat.format(dateInMillis);
    }
}