Example usage for org.joda.time DateTimeZone getDefault

List of usage examples for org.joda.time DateTimeZone getDefault

Introduction

In this page you can find the example usage for org.joda.time DateTimeZone getDefault.

Prototype

public static DateTimeZone getDefault() 

Source Link

Document

Gets the default time zone.

Usage

From source file:org.mythtv.android.utils.DateUtils.java

License:Open Source License

public static String getDateTimeUsingLocaleFormattingPrettyDateOnly(DateTime dateTime, String dateFormat) {
    dateTime = dateTime.withZone(DateTimeZone.getDefault());
    return DateTimeFormat.forPattern(dateFormat).print(dateTime);
}

From source file:org.mythtv.client.ui.BackendStatusFragment.java

License:Open Source License

private View getUpcomingRecView(LayoutInflater inflater, Program program) {

    View view = (View) inflater.inflate(R.layout.backend_status_upcoming_list_item, null, false);

    // set category color
    View category = view.findViewById(R.id.upcoming_category);
    if (null != category)
        category.setBackgroundColor(mProgramHelper.getCategoryColor(program.getCategory()));

    // set upcoming_title
    TextView tView = (TextView) view.findViewById(R.id.upcoming_title);
    if (null != tView) {
        tView.setText(program.getTitle());
    }/*ww w.  j  a va2s.  c om*/

    // set upcoming_sub_title
    tView = (TextView) view.findViewById(R.id.upcoming_sub_title);
    if (null != tView) {
        tView.setText(program.getSubTitle());
    }

    // set upcoming_channel
    tView = (TextView) view.findViewById(R.id.upcoming_channel);
    if (null != tView) {
        tView.setText(program.getChannelInfo().getCallSign());
    }

    // set upcoming_start_time
    tView = (TextView) view.findViewById(R.id.upcoming_start_time);
    if (null != tView) {
        tView.setText(DateUtils.getDayTimeWithLocaleFormatting(
                program.getStartTime().withZone(DateTimeZone.getDefault()),
                getMainApplication().getClockType()));
    }

    // set upcoming_duration
    tView = (TextView) view.findViewById(R.id.upcoming_duration);
    if (null != tView) {
        tView.setText(Long.toString(program.getDurationInMinutes()));
    }

    return view;

}

From source file:org.mythtv.client.ui.dvr.GuideFragment.java

License:Open Source License

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    Log.v(TAG, "onActivityCreated : enter");
    super.onActivityCreated(savedInstanceState);

    setHasOptionsMenu(true);/*www.j ava 2  s.c  o  m*/

    View view = getView();

    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity());
    downloadDays = Integer.parseInt(sp.getString("preference_program_guide_days", "14"));

    mLocationProfile = mLocationProfileDaoHelper.findConnectedProfile(getActivity());

    channels = mChannelDaoHelper.findAll(getActivity(), mLocationProfile);
    selectedChannelId = channels.get(0).getChanId();

    today = new DateTime(DateTimeZone.getDefault()).withTimeAtStartOfDay();
    selectedDate = today;
    Log.v(TAG, "onActivityCreated : selectedDate=" + selectedDate.toString());

    //      dateRange.add( today );
    //      for( int i = 1; i < downloadDays; i++ ) {
    //         dateRange.add( today.plusDays( i ) );
    //      }

    //      mProgramGuideDate = (TextView) getActivity().findViewById( R.id.program_guide_date );
    //      mProgramGuideDate.setText( DateUtils.getDateTimeUsingLocaleFormattingPrettyDateOnly( today, getMainApplication().getDateFormat() ) );

    // get child fragment manager
    mFragmentManager = getChildFragmentManager();

    // look for program guide channels list placeholder frame layout
    FrameLayout channelsLayout = (FrameLayout) view.findViewById(R.id.frame_layout_program_guide_channels);
    if (null != channelsLayout) {
        Log.v(TAG, "onActivityCreated : loading channels fragment");

        mGuideChannelFragment = (GuideChannelFragment) mFragmentManager
                .findFragmentByTag(GuideChannelFragment.class.getName());
        if (null == mGuideChannelFragment) {
            mGuideChannelFragment = (GuideChannelFragment) GuideChannelFragment.instantiate(getActivity(),
                    GuideChannelFragment.class.getName());
            mGuideChannelFragment.setOnChannelScrollListener(this);
        }

        mFragmentManager.beginTransaction().replace(R.id.frame_layout_program_guide_channels,
                mGuideChannelFragment, GuideChannelFragment.class.getName()).commit();

    }

    /*      FrameLayout timeslotsLayout = (FrameLayout) view.findViewById( R.id.frame_layout_program_guide_timeslots );
          if( null != timeslotsLayout ) {
             Log.v( TAG, "onActivityCreated : loading timeslots fragment" );
                     
             mGuideTimeslotsFragment = (GuideTimeslotsFragment) mFragmentManager.findFragmentByTag( GuideTimeslotsFragment.class.getName() );
             if( null == mGuideTimeslotsFragment ) {
    mGuideTimeslotsFragment = (GuideTimeslotsFragment) GuideTimeslotsFragment.instantiate( getActivity(), GuideTimeslotsFragment.class.getName() );
    mGuideTimeslotsFragment.setOnTimeslotScrollListener( this );
             }
            
             mFragmentManager.beginTransaction()
    .replace( R.id.frame_layout_program_guide_timeslots, mGuideTimeslotsFragment, GuideTimeslotsFragment.class.getName() )
    .commit();
                  
          }
    */
    FrameLayout dataLayout = (FrameLayout) view.findViewById(R.id.frame_layout_program_guide_data);
    if (null != dataLayout) {
        Log.v(TAG, "onActivityCreated : loading data fragment");

        mGuideDataFragment = (GuideDataFragment) mFragmentManager
                .findFragmentByTag(GuideDataFragment.class.getName());
        if (null == mGuideDataFragment) {
            mGuideDataFragment = (GuideDataFragment) GuideDataFragment.instantiate(getActivity(),
                    GuideDataFragment.class.getName());
            //mGuideTimeslotsFragment.setOnDataScrollListener( this );

            Bundle args = new Bundle();
            args.putInt(ProgramConstants.FIELD_CHANNEL_ID, selectedChannelId);
            args.putLong(ProgramConstants.FIELD_END_TIME, selectedDate.getMillis());
            mGuideDataFragment.setArguments(args);

        }

        mFragmentManager.beginTransaction().replace(R.id.frame_layout_program_guide_data, mGuideDataFragment,
                GuideDataFragment.class.getName()).commit();

    }

    Log.v(TAG, "onActivityCreated : exit");
}

From source file:org.mythtv.service.guide.v25.ProgramGuideHelperV25.java

License:Open Source License

private static void downloadProgramGuide(final Context context, final LocationProfile locationProfile)
        throws MythServiceApiRuntimeException, RemoteException, OperationApplicationException {
    Log.v(TAG, "downloadProgramGuide : enter");

    ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();
    ProgramHelperV25.getInstance().deletePrograms(context, locationProfile, ops,
            ProgramConstants.CONTENT_URI_GUIDE, ProgramConstants.TABLE_NAME_GUIDE);
    RecordingHelperV25.getInstance().deleteRecordings(context, locationProfile, ops, ContentDetails.GUIDE);

    DateTime startDownloading = new DateTime();

    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    int downloadDays = Integer.parseInt(sp.getString("preference_program_guide_days", "14"));
    Log.v(TAG, "downloadProgramGuide : downloadDays=" + downloadDays);

    DateTime start = new DateTime(DateTimeZone.getDefault()).withTimeAtStartOfDay();
    DateTime end = start.plusHours(3);/*from   w  w  w.jav  a  2  s .  c  o  m*/
    for (int i = 0; i < ((downloadDays * 24) / 3); i++) {
        Log.i(TAG,
                "downloadProgramGuide : starting download for [" + (i + 1) + " of " + ((downloadDays * 24) / 3)
                        + "] "
                        + DateUtils.getDateTimeUsingLocaleFormattingPretty(start,
                                mMainApplication.getDateFormat(), mMainApplication.getClockType())
                        + ", end time=" + DateUtils.getDateTimeUsingLocaleFormattingPretty(end,
                                mMainApplication.getDateFormat(), mMainApplication.getClockType()));

        EtagInfoDelegate etag = mEtagDaoHelper.findByEndpointAndDataId(context, locationProfile,
                "GetProgramGuide", String.valueOf(i));
        Log.d(TAG, "downloadProgramGuide : etag=" + etag.getValue());

        if (null == etag.getDate() || start.isAfter(etag.getDate())) {
            Log.v(TAG, "downloadProgramGuide : next mythfilldatabase has passed");

            ResponseEntity<ProgramGuide> responseEntity = mMythServicesTemplate.guideOperations()
                    .getProgramGuide(start, end, 1, null, false, etag);

            if (responseEntity.getStatusCode().equals(HttpStatus.OK)) {
                Log.i(TAG, "downloadProgramGuide : GetProgramGuide returned 200 OK");
                ProgramGuide programGuide = responseEntity.getBody();

                if (null != programGuide) {

                    if (null != programGuide) {
                        load(context, locationProfile, programGuide);
                    }

                }

                if (null != etag.getValue()) {
                    Log.i(TAG, "downloadProgramGuide : saving etag: " + etag.getValue());

                    etag.setEndpoint("GetProgramGuide");
                    etag.setDataId(i);
                    etag.setDate(locationProfile.getNextMythFillDatabase());
                    etag.setMasterHostname(locationProfile.getHostname());
                    etag.setLastModified(new DateTime(DateTimeZone.UTC));
                    mEtagDaoHelper.save(context, locationProfile, etag);
                }

            }

            if (responseEntity.getStatusCode().equals(HttpStatus.NOT_MODIFIED)) {
                Log.i(TAG, "downloadProgramGuide : GetProgramGuide returned 304 Not Modified");

                if (null != etag.getValue()) {
                    Log.i(TAG, "downloadProgramGuide : saving etag: " + etag.getValue());

                    etag.setLastModified(new DateTime(DateTimeZone.UTC));
                    mEtagDaoHelper.save(context, locationProfile, etag);
                }

            }

            start = end;
            end = end.plusHours(3);

        } else {
            Log.v(TAG, "downloadProgramGuide : next mythfilldatabase has NOT passed!");
        }

    }

    Log.i(TAG, "downloadProgramGuide : interval=" + new Interval(startDownloading, new DateTime()).toString());

    Log.v(TAG, "downloadProgramGuide : exit");
}

From source file:org.mythtv.service.guide.v26.ProgramGuideHelperV26.java

License:Open Source License

private static void downloadProgramGuide(final Context context, final LocationProfile locationProfile)
        throws MythServiceApiRuntimeException, RemoteException, OperationApplicationException {
    Log.v(TAG, "downloadProgramGuide : enter");

    ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();
    ProgramHelperV26.getInstance().deletePrograms(context, locationProfile, ops,
            ProgramConstants.CONTENT_URI_GUIDE, ProgramConstants.TABLE_NAME_GUIDE);
    RecordingHelperV26.getInstance().deleteRecordings(context, locationProfile, ops, ContentDetails.GUIDE);

    DateTime startDownloading = new DateTime();

    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    int downloadDays = Integer.parseInt(sp.getString("preference_program_guide_days", "14"));
    Log.v(TAG, "downloadProgramGuide : downloadDays=" + downloadDays);

    DateTime start = new DateTime(DateTimeZone.getDefault()).withTimeAtStartOfDay();
    DateTime end = start.plusHours(3);//from  www .  j  a v a 2 s  . c o m
    for (int i = 0; i < ((downloadDays * 24) / 3); i++) {
        Log.i(TAG,
                "downloadProgramGuide : starting download for [" + (i + 1) + " of " + ((downloadDays * 24) / 3)
                        + "] "
                        + DateUtils.getDateTimeUsingLocaleFormattingPretty(start,
                                mMainApplication.getDateFormat(), mMainApplication.getClockType())
                        + ", end time=" + DateUtils.getDateTimeUsingLocaleFormattingPretty(end,
                                mMainApplication.getDateFormat(), mMainApplication.getClockType()));

        EtagInfoDelegate etag = mEtagDaoHelper.findByEndpointAndDataId(context, locationProfile,
                "GetProgramGuide", String.valueOf(i));
        Log.d(TAG, "downloadProgramGuide : etag=" + etag.getValue());

        if (null == etag.getDate() || start.isAfter(etag.getDate())) {
            Log.v(TAG, "downloadProgramGuide : next mythfilldatabase has passed");

            ResponseEntity<ProgramGuide> responseEntity = mMythServicesTemplate.guideOperations()
                    .getProgramGuide(start, end, 1, null, false, etag);

            if (responseEntity.getStatusCode().equals(HttpStatus.OK)) {
                Log.i(TAG, "downloadProgramGuide : GetProgramGuide returned 200 OK");
                ProgramGuide programGuide = responseEntity.getBody();

                if (null != programGuide) {

                    if (null != programGuide) {
                        load(context, locationProfile, programGuide);
                    }

                }

                if (null != etag.getValue()) {
                    Log.i(TAG, "downloadProgramGuide : saving etag: " + etag.getValue());

                    etag.setEndpoint("GetProgramGuide");
                    etag.setDataId(i);
                    etag.setDate(locationProfile.getNextMythFillDatabase());
                    etag.setMasterHostname(locationProfile.getHostname());
                    etag.setLastModified(new DateTime(DateTimeZone.UTC));
                    mEtagDaoHelper.save(context, locationProfile, etag);
                }

            }

            if (responseEntity.getStatusCode().equals(HttpStatus.NOT_MODIFIED)) {
                Log.i(TAG, "downloadProgramGuide : GetProgramGuide returned 304 Not Modified");

                if (null != etag.getValue()) {
                    Log.i(TAG, "downloadProgramGuide : saving etag: " + etag.getValue());

                    etag.setLastModified(new DateTime(DateTimeZone.UTC));
                    mEtagDaoHelper.save(context, locationProfile, etag);
                }

            }

            start = end;
            end = end.plusHours(3);

        } else {
            Log.v(TAG, "downloadProgramGuide : next mythfilldatabase has NOT passed!");
        }

    }

    Log.i(TAG, "downloadProgramGuide : interval=" + new Interval(startDownloading, new DateTime()).toString());

    Log.v(TAG, "downloadProgramGuide : exit");
}

From source file:org.mythtv.service.guide.v27.ProgramGuideHelperV27.java

License:Open Source License

private static void downloadProgramGuide(final Context context, final LocationProfile locationProfile)
        throws MythServiceApiRuntimeException, RemoteException, OperationApplicationException {
    Log.v(TAG, "downloadProgramGuide : enter");

    ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();
    ProgramHelperV27.getInstance().deletePrograms(context, locationProfile, ops,
            ProgramConstants.CONTENT_URI_GUIDE, ProgramConstants.TABLE_NAME_GUIDE);
    RecordingHelperV27.getInstance().deleteRecordings(context, locationProfile, ops, ContentDetails.GUIDE);

    DateTime startDownloading = new DateTime();

    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    int downloadDays = Integer.parseInt(sp.getString("preference_program_guide_days", "14"));
    Log.v(TAG, "downloadProgramGuide : downloadDays=" + downloadDays);

    DateTime start = new DateTime(DateTimeZone.getDefault()).withTimeAtStartOfDay();
    DateTime end = start.plusHours(3);/*from   ww  w  .  j  a v a  2 s  .  c o m*/
    for (int i = 0; i < ((downloadDays * 24) / 3); i++) {
        Log.i(TAG,
                "downloadProgramGuide : starting download for [" + (i + 1) + " of " + ((downloadDays * 24) / 3)
                        + "] "
                        + DateUtils.getDateTimeUsingLocaleFormattingPretty(start,
                                mMainApplication.getDateFormat(), mMainApplication.getClockType())
                        + ", end time=" + DateUtils.getDateTimeUsingLocaleFormattingPretty(end,
                                mMainApplication.getDateFormat(), mMainApplication.getClockType()));

        EtagInfoDelegate etag = mEtagDaoHelper.findByEndpointAndDataId(context, locationProfile,
                "GetProgramGuide", String.valueOf(i));
        Log.d(TAG, "downloadProgramGuide : etag=" + etag.getValue());

        if (null == etag.getDate() || start.isAfter(etag.getDate())) {
            Log.v(TAG, "downloadProgramGuide : next mythfilldatabase has passed");

            ResponseEntity<ProgramGuide> responseEntity = mMythServicesTemplate.guideOperations()
                    .getProgramGuide(start, end, 1, null, false, etag);

            if (responseEntity.getStatusCode().equals(HttpStatus.OK)) {
                Log.i(TAG, "downloadProgramGuide : GetProgramGuide returned 200 OK");
                ProgramGuide programGuide = responseEntity.getBody();

                if (null != programGuide) {

                    if (null != programGuide) {
                        load(context, locationProfile, programGuide);
                    }

                }

                if (null != etag.getValue()) {
                    Log.i(TAG, "downloadProgramGuide : saving etag: " + etag.getValue());

                    etag.setEndpoint("GetProgramGuide");
                    etag.setDataId(i);
                    etag.setDate(locationProfile.getNextMythFillDatabase());
                    etag.setMasterHostname(locationProfile.getHostname());
                    etag.setLastModified(new DateTime(DateTimeZone.UTC));
                    mEtagDaoHelper.save(context, locationProfile, etag);
                }

            }

            if (responseEntity.getStatusCode().equals(HttpStatus.NOT_MODIFIED)) {
                Log.i(TAG, "downloadProgramGuide : GetProgramGuide returned 304 Not Modified");

                if (null != etag.getValue()) {
                    Log.i(TAG, "downloadProgramGuide : saving etag: " + etag.getValue());

                    etag.setLastModified(new DateTime(DateTimeZone.UTC));
                    mEtagDaoHelper.save(context, locationProfile, etag);
                }

            }

            start = end;
            end = end.plusHours(3);

        } else {
            Log.v(TAG, "downloadProgramGuide : next mythfilldatabase has NOT passed!");
        }

    }

    Log.i(TAG, "downloadProgramGuide : interval=" + new Interval(startDownloading, new DateTime()).toString());

    Log.v(TAG, "downloadProgramGuide : exit");
}

From source file:org.odk.collect.android.widgets.QuestionWidget.java

License:Apache License

protected LocalDateTime skipDaylightSavingGapIfExists(LocalDateTime ldt) {
    while (DateTimeZone.getDefault().isLocalDateTimeGap(ldt)) {
        ldt = ldt.plusMinutes(1);/* w w  w  .j  av a2s .  com*/
    }
    return ldt;
}

From source file:org.ohmage.reminders.base.TriggerBase.java

License:Apache License

/**
 * Updates the pending state for surveys. It doesn't check to see if the survey should actually
 * be pending so callers must know that the state is correct.
 *
 * @param context/*from  w w w. j a  v a 2 s  .  c o m*/
 * @param time
 * @param surveys
 */
public static void updatePendingStateForSurveys(Context context, long time, String... surveys) {
    StringBuilder select = new StringBuilder();
    for (int i = 0; i < surveys.length; i++) {
        if (select.length() != 0) {
            select.append(" OR ");
        }
        select.append(Reminders._ID + "=?");
    }

    ContentValues values = new ContentValues();
    values.put(Reminders.REMINDER_PENDING_TIME, time);
    values.put(Reminders.REMINDER_PENDING_TIMEZONE, DateTimeZone.getDefault().getID());
    context.getContentResolver().update(Reminders.buildRemindersUri(), values, select.toString(), surveys);
}

From source file:org.onebusaway.nextbus.impl.util.DateUtil.java

License:Apache License

public static List<Long> getWeekdayDateTimes() {
    return getWeekdayDateTimes(DateTimeZone.getDefault().getID());
}

From source file:org.onebusaway.nextbus.impl.util.DateUtil.java

License:Apache License

public static List<Long> getWeekendDateTimes() {
    return getWeekendDateTimes(DateTimeZone.getDefault().getID());
}