Example usage for java.util GregorianCalendar get

List of usage examples for java.util GregorianCalendar get

Introduction

In this page you can find the example usage for java.util GregorianCalendar get.

Prototype

public int get(int field) 

Source Link

Document

Returns the value of the given calendar field.

Usage

From source file:de.ribeiro.android.gso.core.UntisProvider.java

private static String[] ConvertToStupidDateArray(GregorianCalendar gc) {
    ArrayList<String> al = new ArrayList<String>();
    al.add(String.valueOf(gc.get(Calendar.YEAR)));
    al.add(PadLeft(String.valueOf(gc.get(Calendar.MONTH) + 1), 2, '0'));
    al.add(PadLeft(String.valueOf(gc.get(Calendar.DAY_OF_MONTH)), 2, '0'));

    String[] result = new String[al.size()];
    int i = 0;//from w ww.j  a  va2s.  c  o m
    for (String el : al) {
        result[i] = el;
        i++;
    }

    return result;
}

From source file:Spring.Repaso02.ProductoDAO.java

public ArrayList<Producto> consultaAll(GregorianCalendar fecha) {
    int dia = (7 + fecha.get(Calendar.DAY_OF_WEEK) - Calendar.SUNDAY) % 7;
    String selQuery = "select * from TProductos where Disponible = 0 or Disponible = ?";
    List productos = jdbcTemplate.query(selQuery, new Object[] { dia },
            new BeanPropertyRowMapper(Producto.class));
    return (ArrayList) productos;

}

From source file:fr.paris.lutece.plugins.calendar.service.Utils.java

/**
 * Returns the year from a date code// w ww  . j  a v a 2s  .  c  o  m
 * @param strDate The date code
 * @return The Year
 */
public static int getYear(String strDate) {
    SimpleDateFormat format = new SimpleDateFormat(DATE_PATTERN);
    Date date = null;
    try {
        date = format.parse(strDate);
    } catch (ParseException ex) {
        return -1;
    }
    GregorianCalendar calendar = new GregorianCalendar();
    calendar.setTime(date);
    return calendar.get(Calendar.YEAR);
}

From source file:fr.paris.lutece.plugins.calendar.service.Utils.java

/**
 * Returns the month from a date code/*from ww  w. j  av a 2 s  .  co  m*/
 * @param strDate The date code
 * @return The month index (0 - 11)
 */
public static int getMonth(String strDate) {
    SimpleDateFormat format = new SimpleDateFormat(DATE_PATTERN);
    Date date = null;
    try {
        date = format.parse(strDate);
    } catch (ParseException ex) {
        return -1;
    }
    GregorianCalendar calendar = new GregorianCalendar();
    calendar.setTime(date);
    return calendar.get(Calendar.MONTH);
}

From source file:fr.paris.lutece.plugins.calendar.service.Utils.java

/**
 * Returns the day of month from a date code
 * @param strDate The date code//  w  ww .j  a v a  2s  . c o m
 * @return The day
 */
public static int getDay(String strDate) {
    SimpleDateFormat format = new SimpleDateFormat(DATE_PATTERN);
    Date date = null;
    try {
        date = format.parse(strDate);
    } catch (ParseException ex) {
        return -1;
    }
    GregorianCalendar calendar = new GregorianCalendar();
    calendar.setTime(date);
    return calendar.get(Calendar.DAY_OF_MONTH);
}

From source file:fr.paris.lutece.plugins.calendar.service.Utils.java

/**
 * Get the day of week of a given date using the pattern
 * {@link #DATE_PATTERN }/*from  ww w  .j av a 2 s.  c  o  m*/
 * @param strDate The date to parse
 * @return The day of week of the given date, or -1 if the date could not be
 *         parsed
 */
public static int getDayOfWeek(String strDate) {
    SimpleDateFormat format = new SimpleDateFormat(DATE_PATTERN);
    Date date = null;
    try {
        date = format.parse(strDate);
    } catch (ParseException ex) {
        return -1;
    }
    GregorianCalendar calendar = new GregorianCalendar();
    calendar.setTime(date);
    return calendar.get(Calendar.DAY_OF_WEEK);
}

From source file:org.hoteia.qalingo.app.business.job.email.EmailCleanerTasklet.java

public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
    GregorianCalendar calendar = new GregorianCalendar();
    int day = calendar.get(GregorianCalendar.DAY_OF_YEAR);

    // TODO : Denis : 20130924 : add number of day configuration in database

    calendar.set(GregorianCalendar.DAY_OF_YEAR, day - 7);
    int row = emailService.deleteSendedEmail(new Timestamp(calendar.getTimeInMillis()));
    logger.debug(row + " emails deleted");
    return RepeatStatus.FINISHED;
}

From source file:org.hoteia.qalingo.app.business.job.status.ServerStatusCleanerTasklet.java

public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
    GregorianCalendar calendar = new GregorianCalendar();
    int day = calendar.get(GregorianCalendar.DAY_OF_YEAR);

    // TODO : Denis : 20131209 : add number of day configuration in database ?

    calendar.set(GregorianCalendar.DAY_OF_YEAR, day - 7);
    int row = serverService.deleteSendedServerStatus(new Timestamp(calendar.getTimeInMillis()));
    logger.debug(row + " server status deleted");
    return RepeatStatus.FINISHED;
}

From source file:ca.mudar.parkcatcher.ui.fragments.DatePickerFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    ((ParkingApp) getActivity().getApplicationContext()).updateUiLanguage();

    final GregorianCalendar c = mListener.getParkingCalendar();
    int year = c.get(Calendar.YEAR);
    int month = c.get(Calendar.MONTH);
    int day = c.get(Calendar.DAY_OF_MONTH);

    return new DatePickerDialog(getActivity(), this, year, month, day);
}

From source file:ca.mudar.parkcatcher.ui.fragments.TimePickerFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    ((ParkingApp) getActivity().getApplicationContext()).updateUiLanguage();

    final GregorianCalendar c = mListener.getParkingCalendar();
    int hour = c.get(Calendar.HOUR_OF_DAY);
    int minute = c.get(Calendar.MINUTE);

    // Create a new instance of TimePickerDialog and return it
    return new TimePickerDialog(getActivity(), this, hour, minute, DateFormat.is24HourFormat(getActivity()));
}