Example usage for java.util Calendar AM_PM

List of usage examples for java.util Calendar AM_PM

Introduction

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

Prototype

int AM_PM

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

Click Source Link

Document

Field number for get and set indicating whether the HOUR is before or after noon.

Usage

From source file:helper.util.DateHelper.java

/**
 * Take a local time calendar and represent it as a UTC day
 * (truncate to day, retain yy/mm/dd from original date)
 **///ww  w .j a  va  2s.c om
public static Calendar asUtcDay(Calendar localTimeCalendar) {
    Calendar utcDate = Calendar.getInstance(DateUtils.UTC_TIME_ZONE);
    utcDate.clear();
    utcDate.set(localTimeCalendar.get(Calendar.YEAR), localTimeCalendar.get(Calendar.MONTH),
            localTimeCalendar.get(Calendar.DATE), 0, 0, 0);
    utcDate.set(Calendar.AM_PM, Calendar.AM);
    utcDate.set(Calendar.MILLISECOND, 0);
    utcDate.set(Calendar.HOUR, 0);
    return utcDate;
}

From source file:com.licubeclub.zionhs.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Calendar Cal = Calendar.getInstance();
    AMorPM = Cal.get(Calendar.AM_PM);
    DAYofWEEK = Cal.get(Calendar.DAY_OF_WEEK);
    DAYofMONTH = Cal.get(Calendar.DAY_OF_MONTH);

    Log.d("DAYofMONTH", String.valueOf(Cal.get(Calendar.DAY_OF_MONTH)));

    cManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    mobile = cManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
    wifi = cManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);

    setContentView(R.layout.activity_main);

    /*/*  w  w w  .  j a v  a 2s .c om*/
    * TODO - ?    (/?/?)
    * */
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    MEAL = (TextView) findViewById(R.id.mealdata);
    SCHEDULE = (TextView) findViewById(R.id.schedata);
    NOTIPARNTS = (TextView) findViewById(R.id.notiparentdata);
    NOTICES = (TextView) findViewById(R.id.notidata);

    View notices = findViewById(R.id.notices);
    View meal = findViewById(R.id.meal);
    View schedule = findViewById(R.id.schedule);
    View notices_parents = findViewById(R.id.notices_parents);

    notices.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent0 = new Intent(MainActivity.this, Notices.class);
            intent0.putExtra("url",
                    "http://www.zion.hs.kr/main.php?menugrp=110100&master=bbs&act=list&master_sid=58");
            intent0.putExtra("title", getResources().getString(R.string.notices));
            startActivity(intent0);
        }
    });

    meal.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(MainActivity.this, MealActivity.class);
            startActivity(intent);
        }
    });

    schedule.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(MainActivity.this, Schedule.class);
            startActivity(intent);
        }
    });

    notices_parents.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(MainActivity.this, Notices.class);
            intent.putExtra("url",
                    "http://www.zion.hs.kr/main.php?menugrp=110200&master=bbs&act=list&master_sid=59");
            intent.putExtra("title", getResources().getString(R.string.title_activity_notices__parents));
            startActivity(intent);
        }
    });

    //Navigation Drawer
    DrawerArray = new ArrayList<String>();
    DrawerArray.add(getString(R.string.meal));
    DrawerArray.add(getString(R.string.schedule));
    DrawerArray.add(getString(R.string.title_activity_notices__parents));
    DrawerArray.add(getString(R.string.notices));
    DrawerArray.add(getString(R.string.schoolintro));
    DrawerArray.add(getString(R.string.schoolinfo));
    DrawerArray.add(getString(R.string.appsettings_apinfo_title));

    IconArray = new ArrayList<Drawable>();
    IconArray.add(getResources().getDrawable(R.drawable.ic_meal));
    IconArray.add(getResources().getDrawable(R.drawable.ic_event_black_24dp));
    IconArray.add(getResources().getDrawable(R.drawable.ic_insert_drive_file_black_24dp));
    IconArray.add(getResources().getDrawable(R.drawable.ic_speaker_notes_black_24dp));
    IconArray.add(getResources().getDrawable(R.drawable.ic_intro));
    IconArray.add(getResources().getDrawable(R.drawable.ic_school));
    IconArray.add(getResources().getDrawable(R.drawable.ic_info_black_24dp));

    NavigationDrawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    DrawerList = (ListView) findViewById(R.id.left_drawer);

    Adapter = new DrawerListAdapter(this, DrawerArray, IconArray);
    DrawerList.setAdapter(Adapter);

    //Listen for Navigation Drawer State
    DrawerToggle = new ActionBarDrawerToggle(this, NavigationDrawer, R.string.drawer_open,
            R.string.drawer_close) {
        /** Called when a drawer has settled in a completely closed state. */
        public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
            isNavDrawerOpen = false;
        }

        /** Called when a drawer has settled in a completely open state. */
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            //                getSupportActionBar().setBackgroundDrawable(Darkblue);
            isNavDrawerOpen = true;
        }

    };
    NavigationDrawer.setDrawerListener(DrawerToggle);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);

    //Drawer Item Click action
    DrawerList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            switch (position) {
            case 0:
                startActivity(new Intent(MainActivity.this, MealActivity.class));
                break;
            case 1:
                startActivity(new Intent(MainActivity.this, Schedule.class));
                break;
            case 2:
                Intent intent = new Intent(MainActivity.this, Notices.class);
                intent.putExtra("url",
                        "http://www.zion.hs.kr/main.php?menugrp=110200&master=bbs&act=list&master_sid=59");
                intent.putExtra("title", getResources().getString(R.string.title_activity_notices__parents));
                startActivity(intent);
                break;
            case 3:
                Intent intent0 = new Intent(MainActivity.this, Notices.class);
                intent0.putExtra("url",
                        "http://www.zion.hs.kr/main.php?menugrp=110100&master=bbs&act=list&master_sid=58");
                intent0.putExtra("title", getResources().getString(R.string.notices));
                startActivity(intent0);
                break;
            case 4:
                startActivity(new Intent(MainActivity.this, Schoolintro.class));
                break;
            case 5:
                startActivity(new Intent(MainActivity.this, Schoolinfo.class));
                break;
            case 6:
                startActivity(new Intent(MainActivity.this, Appinfo.class));
                break;
            }
        }
    });

    SRL = (SwipeRefreshLayout) findViewById(R.id.swiperefresh);
    if (mobile.isConnected() || wifi.isConnected()) {
        networkTask();
    } else {

        Toast toast = Toast.makeText(getApplicationContext(),
                getResources().getString(R.string.network_connection_warning), Toast.LENGTH_LONG);
        toast.setGravity(Gravity.BOTTOM, 0, 0);
        toast.show();
    }
    SRL.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            cManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
            mobile = cManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
            wifi = cManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
            if (mobile.isConnected() || wifi.isConnected()) {
                networkTask();
            } else {

                Toast toast = Toast.makeText(getApplicationContext(),
                        getResources().getString(R.string.network_connection_warning), Toast.LENGTH_LONG);
                toast.setGravity(Gravity.BOTTOM, 0, 0);
                toast.show();
                SRL.setRefreshing(false);
            }
        }
    });

}

From source file:com.brayanarias.alarmproject.receiver.AlarmReceiver.java

private static void setAlarm(Context context, Alarm alarm) {
    try {//  w  w w  . j a v a2  s .  c  om
        PendingIntent pendingIntent = createPendingIntent(context, alarm);
        AlarmManager alarmManager = getAlarmManager(context);
        Calendar actual = Calendar.getInstance();
        actual.set(Calendar.SECOND, 0);
        actual.set(Calendar.MILLISECOND, 0);
        Calendar calendar = (Calendar) actual.clone();
        int ampm = alarm.getAmPm().equals("AM") ? Calendar.AM : Calendar.PM;
        if (alarm.getHour() == 12) {
            calendar.set(Calendar.HOUR, 0);
        } else {
            calendar.set(Calendar.HOUR, alarm.getHour());
        }
        calendar.set(Calendar.AM_PM, ampm);
        calendar.set(Calendar.MINUTE, alarm.getMinute());
        int day = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
        if (actual.getTimeInMillis() >= calendar.getTimeInMillis()) {
            if (alarm.getDaysOfAlamr().equals("0000000")) {
                calendar.add(Calendar.DATE, 1);
            } else {
                calendar.add(Calendar.DATE, getDaysFromNextAlarm(alarm.getDaysOfAlamr()));
            }
        } else {
            if (!AlarmUtilities.isToday(alarm.getDaysOfAlamr(), day)) {
                calendar.add(Calendar.DATE, getDaysFromNextAlarm(alarm.getDaysOfAlamr()));
            }
        }

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            AlarmManager.AlarmClockInfo clockInfo = new AlarmManager.AlarmClockInfo(calendar.getTimeInMillis(),
                    pendingIntent);
            alarmManager.setAlarmClock(clockInfo, pendingIntent);
        } else if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
            alarmManager.setExact(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pendingIntent);
        } else {
            alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pendingIntent);
        }

    } catch (Exception e) {
        Log.e(tag, e.getLocalizedMessage(), e);
    }
}

From source file:com.brayanarias.alarmproject.activity.AlarmScreenActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_alarm_screen);
    int alarmId = getIntent().getIntExtra(Constant.alarmIdKey, -1);
    if (alarmId == -1) {
        finish();//from w  ww.j ava2 s  . co  m
    }
    NotificationManager alarmNotificationManager = (NotificationManager) this
            .getSystemService(Context.NOTIFICATION_SERVICE);
    alarmNotificationManager.cancelAll();
    String name = getIntent().getStringExtra(Constant.alarmNameKey);
    if (name == null || name.isEmpty()) {
        name = getString(R.string.app_name);
    }
    String hourFormatted = getIntent().getStringExtra(Constant.alarmHourFormattedKey);
    String msgampm = getIntent().getStringExtra(Constant.alarmAmPmKey);
    String msgNotification = name;
    msgNotification = msgNotification + " - " + hourFormatted + " " + msgampm;
    sendNotification(msgNotification);
    Calendar calendar = Calendar.getInstance();
    String hourText;
    int actualAmPm = calendar.get(Calendar.AM_PM);
    String ampm = actualAmPm == Calendar.AM ? "AM" : "PM";
    int hour = calendar.get(Calendar.HOUR);
    hour = hour == 0 ? 12 : hour;
    int minute = calendar.get(Calendar.MINUTE);
    String minuteString = minute >= 10 ? "" + minute : "0" + minute;
    hourText = hour + ":" + minuteString + " " + ampm;
    TextView tvAlarmHourScreen = (TextView) findViewById(R.id.tvAlarmHourScreen);
    tvAlarmHourScreen.setText(hourText);
    TextView tvAlarmNameScreen = (TextView) findViewById(R.id.tvAlarmNameScreen);
    if (name.equals(getString(R.string.app_name))) {
        name = AlarmUtilities.getSalute(getApplicationContext());
    }
    if (tvAlarmNameScreen != null) {
        tvAlarmNameScreen.setText(name);
    }
    FloatingActionButton btDismiss = (FloatingActionButton) findViewById(R.id.btDismiss);
    if (btDismiss != null) {
        btDismiss.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mediaPlayer != null && mediaPlayer.isPlaying()) {
                    mediaPlayer.stop();
                }
                if (vibrator != null) {
                    vibrator.cancel();
                }
                finish();
            }
        });
    }
    FloatingActionButton btPostpone = (FloatingActionButton) findViewById(R.id.btPostpone);
    if (btPostpone != null) {
        btPostpone.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                int alarmId = getIntent().getIntExtra(Constant.alarmIdKey, -1);
                int postpone = getIntent().getIntExtra(Constant.alarmPostponeKey, -1);
                int minutes = getResources().getIntArray(R.array.alarm_postpone_value_array)[postpone];
                AlarmReceiver.dismissAlarm(alarmId, minutes, getApplicationContext());
                String text = AlarmUtilities.getMessageRemainingPostpone(postpone, getResources());
                Toast.makeText(getApplication(), text, Toast.LENGTH_SHORT).show();
                flag = false;
                finish();
            }
        });
    }
    int postpone = getIntent().getIntExtra(Constant.alarmPostponeKey, -1);
    //postpone configuration
    if (postpone > 0) {
        String timeText = getResources().getStringArray(R.array.alarm_postpone_array)[postpone];
    } else {
        if (btPostpone != null) {
            btPostpone.setEnabled(false);
        }
    }
    String tone = getIntent().getStringExtra(Constant.alarmToneKey);
    playRingtone(tone);
    //Start animation
    starAnimation();
    //Ensure wakelock release
    Runnable releaseWakelock = new Runnable() {

        @Override
        public void run() {
            getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
            getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
            getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
            getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);

            if (wakeLock != null && wakeLock.isHeld()) {
                wakeLock.release();
                if (mediaPlayer != null && mediaPlayer.isPlaying()) {
                    mediaPlayer.stop();
                }
                if (vibrator != null) {
                    vibrator.cancel();
                }
                Log.e(TAG, "Entra a realease wakelock");
                finish();
            }
        }
    };
    new Handler().postDelayed(releaseWakelock, WAKELOCK_TIMEOUT);
}

From source file:DateUtils.java

public static final String getDateTimeFromDate(Date dt, String tzString) {
    try {/*from   w  w  w .  j  a v  a2  s . c o  m*/
        GregorianCalendar gc = new GregorianCalendar();
        gc.setTime(dt);
        gc.setTimeZone(TimeZone.getTimeZone(tzString));
        StringBuffer ret = new StringBuffer();
        ret.append(gc.get(Calendar.YEAR));
        ret.append("-");
        ret.append(gc.get(Calendar.MONTH) - 1);
        ret.append("-");
        ret.append(gc.get(Calendar.DATE));
        ret.append(" ");
        ret.append(gc.get(Calendar.HOUR));
        ret.append(":");
        ret.append(gc.get(Calendar.MINUTE));
        ret.append(" ");
        if (gc.get(Calendar.AM_PM) == 0) {
            ret.append("AM");
        } else {
            ret.append("PM");
        }
        return ret.toString();
    } catch (Exception e) {
        return "";
    }
}

From source file:org.syncope.console.wicket.markup.html.form.DateTimeFieldPanel.java

public DateTimeFieldPanel(final String id, final String name, final IModel<Date> model, final boolean active,
        final String datePattern) {

    super(id, name, model, active);

    this.datePattern = datePattern;

    field = new DateTimeField("field", model);

    final Calendar cal = Calendar.getInstance();

    field.get("hours").add(new AjaxFormComponentUpdatingBehavior("onchange") {

        private static final long serialVersionUID = -1107858522700306810L;

        @Override//from   www. j  av  a2  s  .c  om
        protected void onUpdate(AjaxRequestTarget art) {
            if (((DateTimeField) field).getHours() > 12) {
                cal.set(Calendar.HOUR_OF_DAY, ((DateTimeField) field).getHours());
            } else {
                cal.set(Calendar.HOUR, ((DateTimeField) field).getHours());
            }
            field.setModelObject(cal.getTime());
        }
    });

    field.get("minutes").add(new AjaxFormComponentUpdatingBehavior("onchange") {

        private static final long serialVersionUID = -1107858522700306810L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {
            cal.set(Calendar.MINUTE, ((DateTimeField) field).getMinutes());
            field.setModelObject(cal.getTime());
        }
    });

    field.get("date").add(new AjaxFormComponentUpdatingBehavior("onchange") {

        private static final long serialVersionUID = -1107858522700306810L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {
            cal.setTime(((DateTimeField) field).getDate());

            if ("PM".equals("" + ((DateTimeField) field).getAmOrPm())) {
                cal.set(Calendar.AM_PM, Calendar.PM);
            } else {
                cal.set(Calendar.AM_PM, Calendar.AM);
            }

            field.setModelObject(cal.getTime());
        }
    });

    field.get("amOrPmChoice").add(new AjaxFormComponentUpdatingBehavior("onchange") {

        private static final long serialVersionUID = -1107858522700306810L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {
            if ("PM".equals("" + ((DateTimeField) field).getAmOrPm())) {
                cal.set(Calendar.AM_PM, Calendar.PM);
            } else {
                cal.set(Calendar.AM_PM, Calendar.AM);
            }

            field.setModelObject(cal.getTime());
        }
    });

    add(field.setLabel(new Model(name)).setOutputMarkupId(true));
}

From source file:net.kjmaster.cookiemom.booth.add.AddBoothDialogFragment.java

private void showDateTimeDialog() {
    // Create the dialog
    final Dialog mDateTimeDialog = new Dialog(getActivity());
    // Inflate the root layout
    final RelativeLayout mDateTimeDialogView = (RelativeLayout) getActivity().getLayoutInflater()
            .inflate(R.layout.ui_date_time_dialog, null);
    // Grab widget instance
    final DateTimePicker mDateTimePicker = (DateTimePicker) mDateTimeDialogView
            .findViewById(R.id.DateTimePicker);
    // Check is system is set to use 24h time (this doesn't seem to work as expected though)
    final String timeS = android.provider.Settings.System.getString(getActivity().getContentResolver(),
            android.provider.Settings.System.TIME_12_24);
    final boolean is24h = !(timeS == null || timeS.equals("12"));

    // Update demo TextViews when the "OK" button is clicked
    mDateTimeDialogView.findViewById(R.id.SetDateTime).setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            mDateTimePicker.clearFocus();
            // TODO Auto-generated method stub

            String eventDate = SimpleDateFormat.getDateInstance(DateFormat.LONG)
                    .format(new Date(mDateTimePicker.getDateTimeMillis()));
            ((TextView) getActivity().findViewById(R.id.Date)).setText(eventDate);
            if (mDateTimePicker.is24HourView()) {
                ((TextView) getActivity().findViewById(R.id.Time)).setText(
                        mDateTimePicker.get(Calendar.HOUR_OF_DAY) + ":" + mDateTimePicker.get(Calendar.MINUTE));
            } else {
                NumberFormat fmt = NumberFormat.getNumberInstance();
                fmt.setMinimumIntegerDigits(2);

                ((TextView) getActivity().findViewById(R.id.Time))
                        .setText(fmt.format(mDateTimePicker.get(Calendar.HOUR)) + ":"
                                + fmt.format(mDateTimePicker.get(Calendar.MINUTE)) + " "
                                + (mDateTimePicker.get(Calendar.AM_PM) == Calendar.AM ? "AM" : "PM"));

            }/*  ww  w. j a  v  a2  s . c o m*/

            hiddenDateTime.setText(String.valueOf(mDateTimePicker.getDateTimeMillis()));
            mDateTimeDialog.dismiss();
        }
    });

    // Cancel the dialog when the "Cancel" button is clicked
    mDateTimeDialogView.findViewById(R.id.CancelDialog).setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            // TODO Auto-generated method stub
            mDateTimeDialog.cancel();
        }
    });

    // Reset Date and Time pickers when the "Reset" button is clicked
    mDateTimeDialogView.findViewById(R.id.ResetDateTime).setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            // TODO Auto-generated method stub
            mDateTimePicker.reset();
        }
    });

    // Setup TimePicker
    mDateTimePicker.setIs24HourView(is24h);
    // No title on the dialog window
    mDateTimeDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    // Set the dialog content view
    mDateTimeDialog.setContentView(mDateTimeDialogView);
    // Display the dialog
    mDateTimeDialog.show();
}

From source file:org.callimachusproject.sql.SqlTupleResult.java

private Value value(int col) throws SQLException {
    int type = md.getColumnType(col);
    String str = rs.getString(col);
    if (str == null)
        return null;
    switch (type) {
    case java.sql.Types.NULL:
        return null;
    case java.sql.Types.DATALINK:
        return vf.createURI(str);
    case java.sql.Types.BINARY:
    case java.sql.Types.VARBINARY:
    case java.sql.Types.BIT:
    case java.sql.Types.BLOB:
    case java.sql.Types.LONGVARBINARY:
    case java.sql.Types.JAVA_OBJECT:
        return vf.createLiteral(Hex.encodeHexString(rs.getBytes(col)), XMLSchema.HEXBINARY);
    case java.sql.Types.DECIMAL:
    case java.sql.Types.NUMERIC:
        return vf.createLiteral(str, XMLSchema.DECIMAL);
    case java.sql.Types.TINYINT:
    case java.sql.Types.SMALLINT:
    case java.sql.Types.INTEGER:
    case java.sql.Types.BIGINT:
        return vf.createLiteral(str, XMLSchema.INTEGER);
    case java.sql.Types.DOUBLE:
    case java.sql.Types.FLOAT:
    case java.sql.Types.REAL:
        return vf.createLiteral(str, XMLSchema.DOUBLE);
    case java.sql.Types.BOOLEAN:
        return vf.createLiteral(rs.getBoolean(col));
    case java.sql.Types.DATE:
        GregorianCalendar date = new GregorianCalendar();
        date.setTime(rs.getDate(col));/*from  w  w  w.  j  av a  2s . c  o  m*/
        date.clear(Calendar.AM_PM);
        date.clear(Calendar.HOUR);
        date.clear(Calendar.HOUR_OF_DAY);
        date.clear(Calendar.MINUTE);
        date.clear(Calendar.SECOND);
        date.clear(Calendar.MILLISECOND);
        return vf.createLiteral(df.newXMLGregorianCalendar(date));
    case java.sql.Types.TIME:
        GregorianCalendar time = new GregorianCalendar();
        time.setTime(rs.getTime(col));
        time.clear(Calendar.ERA);
        time.clear(Calendar.YEAR);
        time.clear(Calendar.MONTH);
        time.clear(Calendar.WEEK_OF_YEAR);
        time.clear(Calendar.WEEK_OF_MONTH);
        time.clear(Calendar.DATE);
        time.clear(Calendar.DAY_OF_MONTH);
        time.clear(Calendar.DAY_OF_YEAR);
        time.clear(Calendar.DAY_OF_WEEK);
        time.clear(Calendar.DAY_OF_WEEK_IN_MONTH);
        return vf.createLiteral(df.newXMLGregorianCalendar(time));
    case java.sql.Types.TIMESTAMP:
        return vf.createLiteral(rs.getTimestamp(col));
    case java.sql.Types.SQLXML:
        return vf.createLiteral(str, RDF.XMLLITERAL);
    case java.sql.Types.ARRAY:
    case java.sql.Types.CHAR:
    case java.sql.Types.CLOB:
    case java.sql.Types.DISTINCT:
    case java.sql.Types.LONGNVARCHAR:
    case java.sql.Types.NCHAR:
    case java.sql.Types.NCLOB:
    case java.sql.Types.NVARCHAR:
    case java.sql.Types.OTHER:
    case java.sql.Types.REF:
    case java.sql.Types.ROWID:
    case java.sql.Types.STRUCT:
    case java.sql.Types.VARCHAR:
    default:
        return vf.createLiteral(str);
    }
}

From source file:org.kuali.kfs.pdp.businessobject.PaymentDetail.java

/**
 * Determines if the disbursement date is past the number of days old (configured in system parameter) in which actions can take
 * place/*from www .j a v  a  2 s.  c  om*/
 * 
 * @return true if actions are allowed on disbursement, false otherwise
 */
public boolean isDisbursementActionAllowed() {
    if (paymentGroup.getDisbursementDate() == null) {
        if (PdpConstants.PaymentStatusCodes.EXTRACTED.equals(paymentGroup.getPaymentStatus().getCode())) {
            return false;
        }
        return true;
    }

    String daysStr = SpringContext.getBean(ParameterService.class).getParameterValueAsString(
            PaymentDetail.class, PdpParameterConstants.DISBURSEMENT_CANCELLATION_DAYS);
    int days = Integer.valueOf(daysStr);

    Calendar c = Calendar.getInstance();
    c.add(Calendar.DATE, (days * -1));
    c.set(Calendar.HOUR, 12);
    c.set(Calendar.MINUTE, 0);
    c.set(Calendar.SECOND, 0);
    c.set(Calendar.MILLISECOND, 0);
    c.set(Calendar.AM_PM, Calendar.AM);
    Timestamp lastDisbursementActionDate = new Timestamp(c.getTimeInMillis());

    Calendar c2 = Calendar.getInstance();
    c2.setTime(paymentGroup.getDisbursementDate());
    c2.set(Calendar.HOUR, 11);
    c2.set(Calendar.MINUTE, 59);
    c2.set(Calendar.SECOND, 59);
    c2.set(Calendar.MILLISECOND, 59);
    c2.set(Calendar.AM_PM, Calendar.PM);
    Timestamp disbursementDate = new Timestamp(c2.getTimeInMillis());

    // date is equal to or after lastActionDate Allowed
    return ((disbursementDate.compareTo(lastDisbursementActionDate)) >= 0);
}

From source file:org.eclipse.wb.internal.swing.model.property.editor.models.spinner.SpinnerModelPropertyEditor.java

/**
 * @return the the name of step from {@link Calendar} fields.
 *//*from w  w  w .ja  v a  2  s  . c  o  m*/
private static String getDateStep(int calendarField) {
    switch (calendarField) {
    case Calendar.ERA:
        return "ERA";
    case Calendar.YEAR:
        return "YEAR";
    case Calendar.MONTH:
        return "MONTH";
    case Calendar.WEEK_OF_YEAR:
        return "WEEK_OF_YEAR";
    case Calendar.WEEK_OF_MONTH:
        return "WEEK_OF_MONTH";
    case Calendar.DAY_OF_MONTH:
        return "DAY_OF_MONTH";
    case Calendar.DAY_OF_YEAR:
        return "DAY_OF_YEAR";
    case Calendar.DAY_OF_WEEK:
        return "DAY_OF_WEEK";
    case Calendar.DAY_OF_WEEK_IN_MONTH:
        return "DAY_OF_WEEK_IN_MONTH";
    case Calendar.AM_PM:
        return "AM_PM";
    case Calendar.HOUR:
        return "HOUR";
    case Calendar.HOUR_OF_DAY:
        return "HOUR_OF_DAY";
    case Calendar.MINUTE:
        return "MINUTE";
    case Calendar.SECOND:
        return "SECOND";
    case Calendar.MILLISECOND:
        return "MILLISECOND";
    default:
        return null;
    }
}