Example usage for java.util Calendar SUNDAY

List of usage examples for java.util Calendar SUNDAY

Introduction

In this page you can find the example usage for java.util Calendar SUNDAY.

Prototype

int SUNDAY

To view the source code for java.util Calendar SUNDAY.

Click Source Link

Document

Value of the #DAY_OF_WEEK field indicating Sunday.

Usage

From source file:de.ribeiro.android.gso.dataclasses.Pager.java

private String ResolveWeekDay(int value) {
    switch (value) {
    case Calendar.MONDAY:
        return "Montag";
    case Calendar.TUESDAY:
        return "Dienstag";
    case Calendar.WEDNESDAY:
        return "Mittwoch";
    case Calendar.THURSDAY:
        return "Donnerstag";
    case Calendar.FRIDAY:
        return "Freitag";
    case Calendar.SATURDAY:
        return "Samstag";
    case Calendar.SUNDAY:
        return "Sonntag";
    default:/*from ww w. j  a  va2  s.  c  o  m*/
        return String.valueOf(value);
    }

}

From source file:org.everit.jira.timetracker.plugin.JiraTimetrackerPluginImpl.java

@Override
public Date firstMissingWorklogsDate(final String selectedUser) throws GenericEntityException {
    Calendar scannedDate = Calendar.getInstance();
    // one week//w  w w  . j av  a  2 s.co m
    scannedDate.set(Calendar.DAY_OF_YEAR,
            scannedDate.get(Calendar.DAY_OF_YEAR) - DateTimeConverterUtil.DAYS_PER_WEEK);
    for (int i = 0; i < DateTimeConverterUtil.DAYS_PER_WEEK; i++) {
        // convert date to String
        Date scanedDateDate = scannedDate.getTime();
        String scanedDateString = DateTimeConverterUtil.dateToString(scanedDateDate);
        // check excludse - pass
        if (excludeDatesSet.contains(scanedDateString)) {
            scannedDate.set(Calendar.DAY_OF_YEAR, scannedDate.get(Calendar.DAY_OF_YEAR) + 1);
            continue;
        }
        // check includes - not check weekend
        // check weekend - pass
        if (!includeDatesSet.contains(scanedDateString)
                && ((scannedDate.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY)
                        || (scannedDate.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY))) {
            scannedDate.set(Calendar.DAY_OF_YEAR, scannedDate.get(Calendar.DAY_OF_YEAR) + 1);
            continue;
        }
        // check worklog. if no worklog set result else ++ scanedDate
        boolean isDateContainsWorklog = isContainsWorklog(scanedDateDate);
        if (!isDateContainsWorklog) {
            return scanedDateDate;
        } else {
            scannedDate.set(Calendar.DAY_OF_YEAR, scannedDate.get(Calendar.DAY_OF_YEAR) + 1);
        }
    }
    // if we find everything all right then return with the current date
    return scannedDate.getTime();
}

From source file:com.espertech.esper.regression.pattern.TestCronParameter.java

private int getLastWeekDayOfMonth(Integer day, int year) {
    int computeDay = (day == null) ? getLastDayOfMonth(year) : day;
    setTime(year);/*from  w  w w  .  java  2 s. c  o  m*/
    if (!checkDayValidInMonth(computeDay, calendar.get(Calendar.MONTH), calendar.get(Calendar.YEAR))) {
        throw new IllegalArgumentException("Invalid day for " + calendar.get(Calendar.MONTH));
    }
    calendar.set(Calendar.DAY_OF_MONTH, computeDay);
    int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
    if ((dayOfWeek >= Calendar.MONDAY) && (dayOfWeek <= Calendar.FRIDAY)) {
        return computeDay;
    }
    if (dayOfWeek == Calendar.SATURDAY) {
        if (computeDay == 1) {
            calendar.add(Calendar.DAY_OF_MONTH, +2);
        } else {
            calendar.add(Calendar.DAY_OF_MONTH, -1);
        }
    }
    if (dayOfWeek == Calendar.SUNDAY) {
        if ((computeDay == 28) || (computeDay == 29) || (computeDay == 30) || (computeDay == 31)) {
            calendar.add(Calendar.DAY_OF_MONTH, -2);
        } else {
            calendar.add(Calendar.DAY_OF_MONTH, +2);
        }
    }
    return calendar.get(Calendar.DAY_OF_MONTH);
}

From source file:org.pentaho.di.trans.steps.script.ScriptAddedFunctions.java

public static Object isWorkingDay(ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
        Object FunctionContext) {
    if (ArgList.length == 1) {
        try {//from  ww  w .  j  a  v  a 2s  . co  m
            if (isNull(ArgList[0])) {
                return null;
            } else if (isUndefined(ArgList[0])) {
                return undefinedValue;
            } else {
                java.util.Date dIn = (java.util.Date) ArgList[0];
                Calendar startDate = Calendar.getInstance();
                startDate.setTime(dIn);
                if (startDate.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY
                        && startDate.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) {
                    return Boolean.TRUE;
                }
                return Boolean.FALSE;
            }
        } catch (Exception e) {
            return null;
        }
    } else {
        throw new RuntimeException("The function call isWorkingDay requires 1 argument.");
    }
}

From source file:Time.java

/**
 * Get default locale name of this day ("Monday", "Tuesday", etc.
 * /*  www .j a  va2  s . c o m*/
 * @return Name of day.
 */
public String getDayName() {
    switch (getDayOfWeek()) {
    case Calendar.MONDAY:
        return "Monday";
    case Calendar.TUESDAY:
        return "Tuesday";
    case Calendar.WEDNESDAY:
        return "Wednesday";
    case Calendar.THURSDAY:
        return "Thursday";
    case Calendar.FRIDAY:
        return "Friday";
    case Calendar.SATURDAY:
        return "Saturday";
    case Calendar.SUNDAY:
        return "Sunday";
    }

    // This will never happen
    return null;
}

From source file:com.akretion.kettle.steps.terminatooor.ScriptValuesAddedFunctions.java

public static Object isWorkingDay(ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
        Object FunctionContext) {
    if (ArgList.length == 1) {
        try {/* w  ww.jav a 2  s  .c o  m*/
            if (isNull(ArgList[0]))
                return null;
            else if (isUndefined(ArgList[0]))
                return undefinedValue;
            else {
                java.util.Date dIn = (java.util.Date) ArgList[0];
                Calendar startDate = Calendar.getInstance();
                startDate.setTime(dIn);
                if (startDate.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY
                        && startDate.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY)
                    return Boolean.TRUE;
                return Boolean.FALSE;
            }
        } catch (Exception e) {
            return null;
        }
    } else {
        throw new RuntimeException("The function call isWorkingDay requires 1 argument.");
    }
}

From source file:ca.mudar.parkcatcher.ui.activities.MainActivity.java

private void updateParkingTimeFromUri(Uri uri) {
    Log.v(TAG, "updateParkingTimeFromUri");
    List<String> pathSegments = uri.getPathSegments();

    // http://www.capteurdestationnement.com/map/search/2/15.5/12
    // http://www.capteurdestationnement.com/map/search/2/15.5/12/h2w2e7

    if ((pathSegments.size() >= 5) && (pathSegments.get(0).equals(Const.INTENT_EXTRA_URL_PATH_MAP))
            && (pathSegments.get(1).equals(Const.INTENT_EXTRA_URL_PATH_SEARCH))) {

        try {//from  ww  w . j  a  v a 2  s  .c  o m
            final int day = Integer.valueOf(pathSegments.get(2));
            final double time = Double.valueOf(pathSegments.get(3));
            final int duration = Integer.valueOf(pathSegments.get(4));

            final int hourOfDay = (int) time;
            final int minute = (int) ((time - hourOfDay) * 60);

            GregorianCalendar calendar = new GregorianCalendar();

            calendar.set(Calendar.DAY_OF_WEEK, day == 7 ? Calendar.SUNDAY : day + 1);
            calendar.set(Calendar.HOUR_OF_DAY, hourOfDay);
            calendar.set(Calendar.MINUTE, minute);

            parkingApp.setParkingCalendar(calendar);
            parkingApp.setParkingDuration(duration);
        } catch (NumberFormatException e) {
            e.printStackTrace();
        }
    }
}

From source file:com.frey.repo.DateUtil.java

/*****************************************
 * @ ??//from  w  ww . j  a v  a  2s  .c om
 ****************************************/
public static String getYearWeekFirstDay(Date curDate) {

    Calendar cal = Calendar.getInstance();
    cal.setTime(curDate);
    if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {
        cal.set(Calendar.WEEK_OF_YEAR, cal.get(Calendar.WEEK_OF_YEAR) - 1);
    } else {
        cal.set(Calendar.WEEK_OF_YEAR, cal.get(Calendar.WEEK_OF_YEAR));
    }
    cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
    String tempYear = Integer.toString(cal.get(Calendar.YEAR));
    String tempMonth = Integer.toString(cal.get(Calendar.MONTH) + 1);
    String tempDay = Integer.toString(cal.get(Calendar.DATE));
    String tempDate = tempYear + "-" + tempMonth + "-" + tempDay;
    return setDateFormat(tempDate, "yyyy-MM-dd");

}

From source file:com.lastsoft.plog.adapter.GameAdapter.java

public void playPopup(View v, final int position) {

    try {/*from  w ww.j av  a  2 s  .  c  o  m*/
        InputMethodManager inputManager = (InputMethodManager) mActivity
                .getSystemService(Context.INPUT_METHOD_SERVICE);

        inputManager.hideSoftInputFromWindow(mActivity.getCurrentFocus().getWindowToken(),
                InputMethodManager.HIDE_NOT_ALWAYS);
    } catch (Exception ignored) {
    }

    PopupMenu popup = new PopupMenu(mActivity, v);

    MenuInflater inflater = popup.getMenuInflater();

    if (games.get(position).expansionFlag == true) {
        inflater.inflate(R.menu.game_expansion_overflow, popup.getMenu());
    } else {
        inflater.inflate(R.menu.game_overflow, popup.getMenu());
    }
    if (games.get(position).gameBGGID == null || games.get(position).gameBGGID.equals("")) {
        popup.getMenu().removeItem(R.id.update_bgg);
        popup.getMenu().removeItem(R.id.open_bgg);
        popup.getMenu().removeItem(R.id.add_bgg);
    }
    if (games.get(position).gameBoxImage == null || games.get(position).gameBoxImage.equals("")) {
        popup.getMenu().removeItem(R.id.view_box_photo);
    }
    if (games.get(position).taggedToPlay <= 0) {
        popup.getMenu().removeItem(R.id.remove_bucket_list);
    } else {
        popup.getMenu().removeItem(R.id.add_bucket_list);
    }

    SharedPreferences app_preferences;
    app_preferences = PreferenceManager.getDefaultSharedPreferences(mActivity);
    long currentDefaultPlayer = app_preferences.getLong("defaultPlayer", -1);
    if (games.get(position).collectionFlag || currentDefaultPlayer == -1) {
        popup.getMenu().removeItem(R.id.add_bgg);
    }

    //check if this game has been played
    //if so, can't delete
    if (GamesPerPlay.hasGameBeenPlayed(games.get(position))) {
        popup.getMenu().removeItem(R.id.delete_game);
    }
    popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            switch (item.getItemId()) {
            case R.id.delete_game:
                ((MainActivity) mActivity).deleteGame(games.get(position).getId());
                return true;
            case R.id.add_tenbyten:
                ((MainActivity) mActivity).addToTenXTen(games.get(position).getId());
                return true;
            case R.id.view_plays:
                if (games.get(position).expansionFlag == true) {
                    ((MainActivity) mActivity).openPlays(games.get(position).gameName, false, 9, fragmentName,
                            currentYear);
                } else {
                    ((MainActivity) mActivity).openPlays(games.get(position).gameName, false, 0, fragmentName,
                            currentYear);
                }
                return true;
            case R.id.open_bgg:
                Intent browserIntent = new Intent(Intent.ACTION_VIEW,
                        Uri.parse("http://bgg.cc/boardgame/" + games.get(position).gameBGGID));
                mActivity.startActivity(browserIntent);
                return true;
            case R.id.update_bgg:
                mPosition = position;
                if (games.get(position).expansionFlag == true) {
                    ((MainActivity) mActivity).searchGameViaBGG(games.get(position).gameName, false, true, -1);
                } else {
                    ((MainActivity) mActivity).searchGameViaBGG(games.get(position).gameName, false, false, -1);
                }
                return true;
            case R.id.add_bgg:
                mPosition = position;
                ((MainActivity) mActivity).updateGameViaBGG(games.get(position).gameName,
                        games.get(position).gameBGGID, "", true, false);
                return true;
            case R.id.add_box_photo:
                ((GamesFragment) mFragment).captureBox(games.get(position));
                return true;
            case R.id.view_box_photo:
                String[] photoParts = games.get(position).gameBoxImage.split("/");
                File newFile = new File(
                        Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)
                                + "/Plog/",
                        photoParts[photoParts.length - 1]);
                Uri contentUri = FileProvider.getUriForFile(mActivity.getApplicationContext(),
                        "com.lastsoft.plog.fileprovider", newFile);
                Intent intent = new Intent();
                intent.setAction(Intent.ACTION_VIEW);
                intent.setDataAndType(contentUri, "image/*");
                intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
                mActivity.startActivity(intent);
                return true;
            case R.id.add_bucket_list:
                String[] ids = TimeZone.getAvailableIDs(-5 * 60 * 60 * 1000);
                // if no ids were returned, something is wrong. get out.
                //if (ids.length == 0)
                //    System.exit(0);

                // begin output
                //System.out.println("Current Time");

                // create a Eastern Standard Time time zone
                SimpleTimeZone pdt = new SimpleTimeZone(-5 * 60 * 60 * 1000, ids[0]);

                // set up rules for daylight savings time
                pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
                pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);

                // create a GregorianCalendar with the Pacific Daylight time zone
                // and the current date and time
                Calendar calendar = new GregorianCalendar(pdt);
                Date trialTime = new Date();
                calendar.setTime(trialTime);
                int i = (int) (calendar.getTime().getTime() / 1000);
                games.get(position).taggedToPlay = i;
                games.get(position).save();

                Snackbar.make(((GamesFragment) mFragment).mCoordinatorLayout,
                        games.get(position).gameName + mActivity.getString(R.string.added_to_bl),
                        Snackbar.LENGTH_LONG)
                        .setAction(mActivity.getString(R.string.undo), new View.OnClickListener() {
                            @Override
                            public void onClick(View view) {
                                games.get(position).taggedToPlay = 0;
                                games.get(position).save();
                                if (playListType == 2) {
                                    ((MainActivity) mActivity).onFragmentInteraction("refresh_games");
                                }
                            }
                        }).show(); // Do not forget to show!

                return true;
            case R.id.remove_bucket_list:
                final int taggedToPlay = games.get(position).taggedToPlay;
                final Game gameToUndo = games.get(position);
                games.get(position).taggedToPlay = 0;
                games.get(position).save();

                Snackbar.make(((GamesFragment) mFragment).mCoordinatorLayout,
                        games.get(position).gameName + mActivity.getString(R.string.removed_from_bl),
                        Snackbar.LENGTH_LONG)
                        .setAction(mActivity.getString(R.string.undo), new View.OnClickListener() {
                            @Override
                            public void onClick(View view) {
                                gameToUndo.taggedToPlay = taggedToPlay;
                                gameToUndo.save();
                                if (playListType == 2) {
                                    ((MainActivity) mActivity).onFragmentInteraction("refresh_games");
                                }
                            }
                        }).show(); // Do not forget to show!
                if (playListType == 2) {
                    ((MainActivity) mActivity).onFragmentInteraction("refresh_games");
                }
                return true;
            default:
                return false;
            }
        }
    }

    );
    popup.show();
}

From source file:org.sakaiproject.tool.section.jsf.backingbean.AddSectionsBean.java

public String getSunday() {
    return daysOfWeek[Calendar.SUNDAY];
}