Example usage for java.util Date setHours

List of usage examples for java.util Date setHours

Introduction

In this page you can find the example usage for java.util Date setHours.

Prototype

@Deprecated
public void setHours(int hours) 

Source Link

Document

Sets the hour of this Date object to the specified value.

Usage

From source file:com.dalamar.model.LateTrainDaoImpl.java

private Conjunction createDateCriterion(Date d) {
    d.setHours(0);
    d.setMinutes(0);//from w ww  . java2  s  .c om
    d.setSeconds(0);
    Date beginDate = d;
    Date endDate = new Date(beginDate.getTime() + TimeUnit.DAYS.toMillis(1));
    Conjunction andOperator = Restrictions.conjunction();
    andOperator.add(Restrictions.ge("dateCaptured", beginDate));
    andOperator.add(Restrictions.lt("dateCaptured", endDate));
    return andOperator;
}

From source file:com.dalamar.model.LateTrainDaoImpl.java

private Conjunction createDateCriterion(Date begin, Date end) {
    begin.setHours(0);
    begin.setMinutes(0);//w w  w .  jav a  2 s  .  c  o  m
    begin.setSeconds(0);
    end.setHours(0);
    end.setMinutes(0);
    end.setSeconds(0);
    Date beginDate = begin;
    Date endDate = new Date(end.getTime() + TimeUnit.DAYS.toMillis(1));
    Conjunction andOperator = Restrictions.conjunction();
    andOperator.add(Restrictions.ge("dateCaptured", beginDate));
    andOperator.add(Restrictions.lt("dateCaptured", endDate));
    return andOperator;
}

From source file:br.com.hslife.orcamento.task.AgendamentoTask.java

@Scheduled(fixedDelay = 3600000)
@SuppressWarnings("deprecation")
public void enviarEmailNotificacao() {
    try {/* w  w w  . j  av  a2 s.c  o m*/

        Date inicio = new Date();
        inicio.setHours(0);
        inicio.setMinutes(0);
        inicio.setSeconds(0);

        Date fim = new Date(inicio.getTime());
        fim.setHours(23);
        fim.setMinutes(59);
        fim.setSeconds(59);
        List<Agenda> agendamentos = getService().buscarAgendamentoPorOuDataInicioOuDataFimEAlerta(inicio, fim,
                true);

        // Itera a lista de agendamentos encontrados, e para cada uma envia um e-mail para o usurio
        for (Agenda a : agendamentos) {
            // Se o usurio marcou para no receber notificao o e-mail no ser enviado
            if (getOpcaoSistemaComponent().getNotificarAgendamentosEmail(a.getUsuario())) {

                StringBuilder mensagemEmail = new StringBuilder();

                mensagemEmail.append("Prezado " + a.getUsuario().getNome() + ",\n\n");
                mensagemEmail.append("O seguinte agendamento foi marcado para notific-lo:\n\n");
                mensagemEmail.append(a.getDescricao() + "\n");
                mensagemEmail.append("Tipo: " + a.getTipoAgendamento() + "\n");
                mensagemEmail.append("Perodo: \n" + a.getDateLabel() + "\n");
                mensagemEmail.append("Dia inteiro: " + (a.isDiaInteiro() ? "SIM" : "NO") + "\n");
                mensagemEmail.append("Notas: " + (a.getNotas() == null ? "-" : a.getNotas()) + "\n\n");
                mensagemEmail.append(
                        "Caso no queira mais receber notificaes a respeito desse evento, desmarque a caixa 'Emitir Alerta' nas propriedades do agendamento.\n\n\n");
                mensagemEmail.append("Administrador do Sistema");

                emailComponent.setDestinatario(a.getUsuario().getNome());
                emailComponent.setEmailDestinatario(a.getUsuario().getEmail());
                emailComponent.setAssunto("Oramento Domstico - Lembrete de agendamento");
                emailComponent.setMensagem(mensagemEmail.toString());
                emailComponent.enviarEmail();
            }
        }

    } catch (Exception e) {
        logger.catching(e);
        e.printStackTrace();
    }
}

From source file:org.apache.metron.profiler.client.window.WindowProcessorTest.java

@Test
public void testRepeatWithWeekendExclusion() throws ParseException {
    Window w = WindowProcessor.process("30 minute window every 24 hours from 7 days ago excluding weekends");

    Date now = new Date();
    now.setHours(6); //avoid DST impacts if near Midnight
    List<Range<Long>> intervals = w.toIntervals(now.getTime());
    Assert.assertEquals(5, intervals.size());
}

From source file:org.apache.metron.profiler.client.window.WindowProcessorTest.java

@Test
public void testRepeatWithWeekdayExclusion() throws ParseException {
    Window w = WindowProcessor.process("30 minute window every 24 hours from 7 days ago excluding weekdays");

    Date now = new Date();
    now.setHours(6); //avoid DST impacts if near Midnight
    List<Range<Long>> intervals = w.toIntervals(now.getTime());
    Assert.assertEquals(2, intervals.size());
}

From source file:org.apache.metron.profiler.client.window.WindowProcessorTest.java

@Test
public void testRepeatWithConflictingExclusionInclusion() throws ParseException {
    Window w = WindowProcessor/* w w  w.  j a  v  a  2  s. c o  m*/
            .process("30 minute window every 24 hours from 7 days ago including saturdays excluding weekends");

    Date now = new Date();
    now.setHours(6); //avoid DST impacts if near Midnight
    List<Range<Long>> intervals = w.toIntervals(now.getTime());
    Assert.assertEquals(0, intervals.size());
}

From source file:de.janrenz.app.mediathek.RemoteImageCursorAdapter.java

@SuppressWarnings("deprecation")
@Override//  www  .  j  a v  a 2 s. c om
public void bindView(View v, Context context, Cursor c) {

    String title = c.getString(c.getColumnIndexOrThrow("title"));
    String subtitle = c.getString(c.getColumnIndexOrThrow("subtitle"));
    String imagePath = c.getString(c.getColumnIndexOrThrow("image"));
    String startTime = c.getString(c.getColumnIndexOrThrow("startTime"));
    String startTimeAsTimestamp = c.getString(c.getColumnIndex("startTimeAsTimestamp"));
    String isLive = c.getString(c.getColumnIndex("isLive"));
    if (this.layout == R.layout.headline_item_grid) {
        final View vl = v;

        v.findViewById(R.id.thumbnail).getViewTreeObserver()
                .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
                    @Override
                    public void onGlobalLayout() {

                        try {

                            View imgView = vl.findViewById(R.id.thumbnail);
                            imgView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
                            ViewGroup.LayoutParams layout = imgView.getLayoutParams();
                            layout.height = imgView.getWidth() / 16 * 9;
                            imgView.setLayoutParams(layout);
                        } catch (Exception e) {
                        }
                    }
                });
    }

    /**
     * Next set the text of the entry.
     */
    if (isLive.equalsIgnoreCase("true")) {
        v.findViewById(R.id.live).setVisibility(View.VISIBLE);
        //v.setBackgroundColor(   context.getResources().getColor(R.color.highlight_live_list));
    } else {
        v.findViewById(R.id.live).setVisibility(View.GONE);
        //v.setBackgroundColor(   context.getResources().getColor(R.color.list_background));
    }

    TextView title_text = (TextView) v.findViewById(R.id.text_view);
    if (title_text != null) {
        title_text.setText(title);
    }

    TextView subtitle_text = (TextView) v.findViewById(R.id.text_view_sub);
    if (subtitle_text != null) {
        subtitle_text.setText(subtitle);
    }
    TextView subtitle2_text = (TextView) v.findViewById(R.id.text_view_sub2);
    if (subtitle2_text != null) {
        Date dt = new Date();
        // z.B. 'Fri Jan 26 19:03:56 GMT+01:00 2001'
        dt.setTime(Integer.parseInt(startTimeAsTimestamp) * 1000);
        dt.setHours(0);
        dt.setMinutes(0);
        dt.setSeconds(0);
        subtitle2_text.setText("ARD > " + startTime + " Uhr");
    }
    /**
     * Set the image
     */
    DisplayImageOptions loadingOptions = new DisplayImageOptions.Builder()
            ///.showStubImage(R.drawable.abs__item_background_holo_light)
            //.imageScaleType(ImageScaleType.EXACTLY)
            // .showImageForEmptyUri(R.drawable.ic_empty)
            //  .memoryCache(new WeakMemoryCache())
            .cacheInMemory()
            //.cacheOnDisc()
            .build();
    ImageView image_view = (ImageView) v.findViewById(R.id.thumbnail);

    if (image_view != null) {

        if (this.layout == R.layout.headline_item_grid) {
            imagePath = imagePath + "/" + 320;

        } else {

            imagePath = imagePath + "/" + 150;
        }
        ImageLoader.getInstance().displayImage(imagePath, image_view, loadingOptions);
    }
}

From source file:org.apache.metron.profiler.client.window.WindowProcessorTest.java

@Test
public void testRepeatWithInclusions() {
    {//from   w  w  w  .  ja v a  2s  .  c  om
        Window w = WindowProcessor
                .process("30 minute window every 24 hours from 14 days ago including tuesdays");
        /*
        A window size of 30 minutes
        Starting 14 days ago  and continuing until now
        Gotta be 2 tuesdays in 14 days.
         */
        Date now = new Date();
        now.setHours(6); //avoid DST impacts if near Midnight
        List<Range<Long>> intervals = w.toIntervals(now.getTime());
        Assert.assertEquals(2, intervals.size());
    }
    {
        Window w = WindowProcessor
                .process("30 minute window every 24 hours from 14 days ago including this day of the week");
        /*
        A window size of 30 minutes
        Starting 14 days ago  and continuing until now
        Gotta be 2 days with the same dow in 14 days.
         */
        Date now = new Date();
        now.setHours(6); //avoid DST impacts if near Midnight
        List<Range<Long>> intervals = w.toIntervals(now.getTime());
        Assert.assertEquals(2, intervals.size());
    }
    {
        Window w = WindowProcessor.process("30 minute window every 24 hours from 14 days ago");
        /*
        A window size of 30 minutes
        Starting 14 days ago  and continuing until now
        Gotta be 14 intervals in 14 days.
         */
        Date now = new Date();
        List<Range<Long>> intervals = w.toIntervals(now.getTime());
        Assert.assertEquals(14, intervals.size());
    }
}

From source file:org.benjp.portlet.chat.ChatApplication.java

@Ajax
@Resource//from   w  ww  .j  a  v a2 s . co  m
public Response.Content createTask(String username, String dueDate, String task) {
    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm");
    Date today = new Date();
    today.setHours(0);
    today.setMinutes(0);
    try {
        calendarService_.saveTask(remoteUser_, username, task, today, sdf.parse(dueDate + " 23:59"));
    } catch (ParseException e) {
        log.info("parse exception during task creation");
        return Response.notFound("Error during task creation");
    } catch (Exception e) {
        log.info("exception during task creation");
        return Response.notFound("Error during task creation");
    }

    return Response.ok("{\"status\":\"ok\"}").withMimeType("application/json; charset=UTF-8")
            .withHeader("Cache-Control", "no-cache");

}

From source file:org.exoplatform.chat.portlet.chat.ChatApplication.java

@Ajax
@Resource// ww w .  j a v  a 2s . co m
public Response.Content createTask(String username, String dueDate, String task) {
    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm");
    Date today = new Date();
    today.setHours(0);
    today.setMinutes(0);
    try {
        calendarService_.saveTask(remoteUser_, username, task, today, sdf.parse(dueDate + " 23:59"));
    } catch (ParseException e) {
        LOG.info("parse exception during task creation");
        return Response.notFound("Error during task creation");
    } catch (Exception e) {
        LOG.info("exception during task creation");
        return Response.notFound("Error during task creation");
    }

    return Response.ok("{\"status\":\"ok\"}").withMimeType("application/json; charset=UTF-8")
            .withHeader("Cache-Control", "no-cache");

}