List of usage examples for java.text DateFormat getDateInstance
public static final DateFormat getDateInstance()
From source file:op.care.reports.PnlReport.java
private java.util.List<Component> addCommands() { java.util.List<Component> list = new ArrayList<Component>(); /***//from ww w . ja v a2 s . c o m * _ _ * | \ | | _____ __ * | \| |/ _ \ \ /\ / / * | |\ | __/\ V V / * |_| \_|\___| \_/\_/ * */ if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID)) { JideButton addButton = GUITools.createHyperlinkButton(SYSTools.xx("misc.commands.new"), new ImageIcon(getClass().getResource("/artwork/22x22/bw/add.png")), new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { if (!resident.isActive()) { OPDE.getDisplayManager() .addSubMessage(new DisplayMessage("misc.msg.cantChangeInactiveResident")); return; } new DlgReport(new NReport(resident), new Closure() { @Override public void execute(Object report) { if (report != null) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); final NReport myReport = (NReport) em.merge(report); em.getTransaction().commit(); final String keyYear = Integer .toString(new DateTime(myReport.getPit()).getYear()) + ".year"; if (!cpMap.containsKey(keyYear)) { reloadDisplay(); } else { final String keyDay = DateFormat.getDateInstance() .format(myReport.getPit()); synchronized (contentmap) { contentmap.remove(keyDay); } synchronized (valuecache) { if (valuecache.containsKey(keyDay)) { valuecache.get(keyDay).add(myReport); Collections.sort(valuecache.get(keyDay)); } } synchronized (listUsedCommontags) { boolean reloadSearch = false; for (Commontags ctag : myReport.getCommontags()) { if (!listUsedCommontags.contains(ctag)) { listUsedCommontags.add(ctag); reloadSearch = true; } } if (reloadSearch) { prepareSearchArea(); } } if (minmax.isAfter(new DateTime(myReport.getPit()))) { minmax.setStart(new DateTime(myReport.getPit())); } if (minmax.isBefore(new DateTime(myReport.getPit()))) { minmax.setEnd(new DateTime(myReport.getPit())); } createCP4Day(new LocalDate(myReport.getPit())); expandDay(new LocalDate(myReport.getPit())); buildPanel(); GUITools.scroll2show(jspReports, cpMap.get(keyDay), cpsReports, new Closure() { @Override public void execute(Object o) { GUITools.flashBackground(linemap.get(myReport), Color.YELLOW, 2); } }); } } catch (OptimisticLockException ole) { OPDE.warn(ole); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } else { reloadDisplay(true); } } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } } }); } }); list.add(addButton); } return list; }
From source file:org.opendatakit.briefcase.util.ExportToCsv.java
private boolean emitSubmissionCsv(OutputStreamWriter osw, EncryptionInformation ei, Element submissionElement, TreeElement primarySet, TreeElement treeElement, boolean first, String uniquePath, File instanceDir) throws IOException { // OK -- group with at least one element -- assume no value... // TreeElement list has the begin and end tags for the nested groups. // Swallow the end tag by looking to see if the prior and current // field names are the same. TreeElement prior = null;/*from w w w .j a v a 2 s . com*/ for (int i = 0; i < treeElement.getNumChildren(); ++i) { TreeElement current = (TreeElement) treeElement.getChildAt(i); log.fine(" element name: " + current.getName()); if ((prior != null) && (prior.getName().equals(current.getName()))) { // it is the end-group tag... seems to happen with two adjacent repeat // groups log.info("repeating tag at " + i + " skipping " + current.getName()); prior = current; } else { Element ec = findElement(submissionElement, current.getName()); switch (current.getDataType()) { case org.javarosa.core.model.Constants.DATATYPE_TEXT:/** * Text question * type. */ case org.javarosa.core.model.Constants.DATATYPE_INTEGER:/** * Numeric * question type. These are numbers without decimal points */ case org.javarosa.core.model.Constants.DATATYPE_DECIMAL:/** * Decimal * question type. These are numbers with decimals */ case org.javarosa.core.model.Constants.DATATYPE_CHOICE:/** * This is a * question with alist of options where not more than one option can * be selected at a time. */ case org.javarosa.core.model.Constants.DATATYPE_CHOICE_LIST:/** * This is a * question with alist of options where more than one option can be * selected at a time. */ case org.javarosa.core.model.Constants.DATATYPE_BOOLEAN:/** * Question with * true and false answers. */ case org.javarosa.core.model.Constants.DATATYPE_BARCODE:/** * Question with * barcode string answer. */ default: case org.javarosa.core.model.Constants.DATATYPE_UNSUPPORTED: if (ec == null) { emitString(osw, first, null); } else { emitString(osw, first, getSubmissionValue(ei, current, ec)); } first = false; break; case org.javarosa.core.model.Constants.DATATYPE_DATE: /** * Date question type. This has only date component without time. */ if (ec == null) { emitString(osw, first, null); } else { String value = getSubmissionValue(ei, current, ec); if (value == null || value.length() == 0) { emitString(osw, first, null); } else { Date date = WebUtils.parseDate(value); DateFormat formatter = DateFormat.getDateInstance(); emitString(osw, first, formatter.format(date)); } } first = false; break; case org.javarosa.core.model.Constants.DATATYPE_TIME: /** * Time question type. This has only time element without date */ if (ec == null) { emitString(osw, first, null); } else { String value = getSubmissionValue(ei, current, ec); if (value == null || value.length() == 0) { emitString(osw, first, null); } else { Date date = WebUtils.parseDate(value); DateFormat formatter = DateFormat.getTimeInstance(); emitString(osw, first, formatter.format(date)); } } first = false; break; case org.javarosa.core.model.Constants.DATATYPE_DATE_TIME: /** * Date and Time question type. This has both the date and time * components */ if (ec == null) { emitString(osw, first, null); } else { String value = getSubmissionValue(ei, current, ec); if (value == null || value.length() == 0) { emitString(osw, first, null); } else { Date date = WebUtils.parseDate(value); DateFormat formatter = DateFormat.getDateTimeInstance(); emitString(osw, first, formatter.format(date)); } } first = false; break; case org.javarosa.core.model.Constants.DATATYPE_GEOPOINT: /** * Question with location answer. */ String compositeValue = (ec == null) ? null : getSubmissionValue(ei, current, ec); compositeValue = (compositeValue == null) ? null : compositeValue.trim(); // emit separate lat, long, alt, acc columns... if (compositeValue == null || compositeValue.length() == 0) { for (int count = 0; count < 4; ++count) { emitString(osw, first, null); first = false; } } else { String[] values = compositeValue.split(" "); for (String value : values) { emitString(osw, first, value); first = false; } for (int count = values.length; count < 4; ++count) { emitString(osw, first, null); first = false; } } break; case org.javarosa.core.model.Constants.DATATYPE_BINARY: /** * Question with external binary answer. */ String binaryFilename = getSubmissionValue(ei, current, ec); if (binaryFilename == null || binaryFilename.length() == 0) { emitString(osw, first, null); first = false; } else { if (exportMedia) { int dotIndex = binaryFilename.lastIndexOf("."); String namePart = (dotIndex == -1) ? binaryFilename : binaryFilename.substring(0, dotIndex); String extPart = (dotIndex == -1) ? "" : binaryFilename.substring(dotIndex); File binaryFile = new File(instanceDir, binaryFilename); String destBinaryFilename = binaryFilename; int version = 1; File destFile = new File(outputMediaDir, destBinaryFilename); while (destFile.exists()) { destBinaryFilename = namePart + "-" + (++version) + extPart; destFile = new File(outputMediaDir, destBinaryFilename); } if (binaryFile.exists()) { FileUtils.copyFile(binaryFile, destFile); } emitString(osw, first, MEDIA_DIR + File.separator + destFile.getName()); } else { emitString(osw, first, binaryFilename); } first = false; } break; case org.javarosa.core.model.Constants.DATATYPE_NULL: /* * for nodes that * have no data, * or data type * otherwise * unknown */ if (current.isRepeatable()) { if (prior == null || !current.getName().equals(prior.getName())) { // repeatable group... if (ec == null) { emitString(osw, first, null); first = false; } else { String uniqueGroupPath = uniquePath + "/" + getFullName(current, primarySet); emitString(osw, first, uniqueGroupPath); first = false; // first time processing this repeat group (ignore templates) List<Element> ecl = findElementList(submissionElement, current.getName()); emitRepeatingGroupCsv(ei, ecl, current, uniquePath, uniqueGroupPath, instanceDir); } } } else if (current.getNumChildren() == 0 && current != briefcaseLfd.getSubmissionElement()) { // assume fields that don't have children are string fields. if (ec == null) { emitString(osw, first, null); first = false; } else { emitString(osw, first, getSubmissionValue(ei, current, ec)); first = false; } } else { /* one or more children -- this is a non-repeating group */ first = emitSubmissionCsv(osw, ei, ec, primarySet, current, first, uniquePath, instanceDir); } break; } prior = current; } } return first; }
From source file:com.appeaser.sublimepicker.Sampler.java
private void updateInfoView() { if (mSelectedDate != null) { if (mSelectedDate.getType() == SelectedDate.Type.SINGLE) { llDateRangeHolder.setVisibility(View.GONE); llDateHolder.setVisibility(View.VISIBLE); tvYear.setText(applyBoldStyle("YEAR: ") .append(String.valueOf(mSelectedDate.getStartDate().get(Calendar.YEAR)))); tvMonth.setText(applyBoldStyle("MONTH: ") .append(String.valueOf(mSelectedDate.getStartDate().get(Calendar.MONTH)))); tvDay.setText(applyBoldStyle("DAY: ") .append(String.valueOf(mSelectedDate.getStartDate().get(Calendar.DAY_OF_MONTH)))); } else if (mSelectedDate.getType() == SelectedDate.Type.RANGE) { llDateHolder.setVisibility(View.GONE); llDateRangeHolder.setVisibility(View.VISIBLE); tvStartDate.setText(applyBoldStyle("START: ") .append(DateFormat.getDateInstance().format(mSelectedDate.getStartDate().getTime()))); tvEndDate.setText(applyBoldStyle("END: ") .append(DateFormat.getDateInstance().format(mSelectedDate.getEndDate().getTime()))); }/*from w w w.j a v a 2 s . c om*/ } tvHour.setText(applyBoldStyle("HOUR: ").append(String.valueOf(mHour))); tvMinute.setText(applyBoldStyle("MINUTE: ").append(String.valueOf(mMinute))); tvRecurrenceOption.setText(applyBoldStyle("RECURRENCE OPTION: ").append(mRecurrenceOption)); tvRecurrenceRule.setText(applyBoldStyle("RECURRENCE RULE: ").append(mRecurrenceRule)); rlDateTimeRecurrenceInfo.setVisibility(View.VISIBLE); }
From source file:gob.dp.simco.intervencion.controller.IntervencionController.java
private void buscarActuacionesxEtapa(long idEtapa) { DateFormat df = DateFormat.getDateInstance(); try {/* w ww. j av a 2 s. com*/ intervencionEtapaActuacions = intervencionEtapaActuacionService .intervencionEtapaActuacionBuscar(idEtapa); List<IntervencionEtapaActuacion> lst = new ArrayList<>(); for (IntervencionEtapaActuacion iea : intervencionEtapaActuacions) { if (iea.getActividadId() != null) { Actividad a = actividadService.actividadBuscarOne(iea.getActividadId()); iea.setNombreActividad(a.getNombre()); iea.setCodigoActividad(a.getCodigoActividad()); } if (iea.getFechaCulminacion() != null) { iea.setFechaStringCulminacion(df.format(iea.getFechaCulminacion())); } } intervencionEtapa.setAvance(defineAvance()); } catch (Exception e) { log.error(e.getCause()); } }
From source file:be.shad.tsqb.test.ExamplesTest.java
@Test public void testShowcaseSelectOptions() { Town town = query.from(Town.class); TownProperty dateProp = query.join(town.getProperties(), JoinType.Left); query.joinWith(dateProp).where(dateProp.getPropertyKey()).eq("LastUfoSpottingDate"); TypeSafeSubQuery<Long> cntInhabitantsSQ = query.subquery(Long.class); Person inhabitant = cntInhabitantsSQ.from(Person.class); cntInhabitantsSQ.where(inhabitant.getTown().getId()).eq(town.getId()); cntInhabitantsSQ.select(cntInhabitantsSQ.hqlFunction().count()); TownDetailsDto dto = query.select(TownDetailsDto.class); // select a subselected value into a dto property dto.setInhabitants(cntInhabitantsSQ.select()); // select an embeddable property value into a nested dto property: dto.getNestedDto().setLattitude(town.getGeographicCoordinate().getLattitude()); // select the upper case name into the dto, this upper will be found in the query dto.setName(query.hqlFunction().upper(town.getName()).select()); // select a value of a different type using a converter to convert the selected value, // this will not be seen in the query and is only a post processor dto.setLastUfoSpottingDate(query.select(Date.class, dateProp.getPropertyValue(), new StringToDateTransformer(DateFormat.getDateInstance()))); // when no function is available and the value can't be retrieved another way it's still possible to just inject hql // it doesn't look pretty, and it isn't supposed to.. because you probably shouldn't do this! dto.setCustomString(new CustomTypeSafeValue<>(query, String.class, "'SomeCustomHql'").select()); validate("select " + "(select count(*) from Person hobj3 where hobj3.town.id = hobj1.id) as inhabitants, " + "hobj1.geographicCoordinate.lattitude as nestedDto_lattitude, " + "upper(hobj1.name) as name, " + "hobj2.propertyValue as lastUfoSpottingDate, " + "'SomeCustomHql' as customString " + "from Town hobj1 left join hobj1.properties hobj2 with hobj2.propertyKey = :np1", "LastUfoSpottingDate"); }
From source file:op.care.supervisor.PnlHandover.java
private CollapsiblePane createCP4Day(final LocalDate day) { final String key = DateFormat.getDateInstance().format(day.toDate()); synchronized (cpMap) { if (!cpMap.containsKey(key)) { cpMap.put(key, new CollapsiblePane()); try { cpMap.get(key).setCollapsed(true); } catch (PropertyVetoException e) { e.printStackTrace();/*w w w . ja v a 2 s . c o m*/ } } } final CollapsiblePane cpDay = cpMap.get(key); if (hollidays == null) { hollidays = SYSCalendar.getHolidays(day.getYear(), day.getYear()); } String titleDay = "<html><font size=+1>" + dayFormat.format(day.toDate()) + SYSTools.catchNull(hollidays.get(day), " (", ")") + "</font></html>"; final DefaultCPTitle titleCPDay = new DefaultCPTitle(titleDay, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { cpDay.setCollapsed(!cpDay.isCollapsed()); } catch (PropertyVetoException pve) { // BAH! } } }); final JButton btnAcknowledge = new JButton(SYSConst.icon163ledGreenOn); btnAcknowledge.setAlignmentX(Component.RIGHT_ALIGNMENT); btnAcknowledge.setToolTipText(SYSTools.xx("nursingrecords.handover.tooltips.btnAcknowledge")); btnAcknowledge.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); synchronized (cacheHO) { ArrayList<Handovers> listHO = new ArrayList<Handovers>(cacheHO.get(key)); for (final Handovers ho : listHO) { if (!Handover2UserTools.containsUser(em, ho, OPDE.getLogin().getUser())) { Handovers myHO = em.merge(ho); Handover2User connObj = em .merge(new Handover2User(myHO, em.merge(OPDE.getLogin().getUser()))); myHO.getUsersAcknowledged().add(connObj); } } } synchronized (cacheNR) { ArrayList<NReport> listNR = new ArrayList<NReport>(cacheNR.get(key)); for (final NReport nreport : listNR) { if (!NR2UserTools.containsUser(em, nreport, OPDE.getLogin().getUser())) { NReport myNR = em.merge(nreport); NR2User connObj = em.merge(new NR2User(myNR, em.merge(OPDE.getLogin().getUser()))); myNR.getUsersAcknowledged().add(connObj); } } } em.getTransaction().commit(); createCP4Day(day); buildPanel(); } catch (OptimisticLockException ole) { OPDE.warn(ole); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage()); } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } }); titleCPDay.getRight().add(btnAcknowledge); cpDay.setTitleLabelComponent(titleCPDay.getMain()); cpDay.setSlidingDirection(SwingConstants.SOUTH); if (hollidays.containsKey(day)) { cpDay.setBackground(SYSConst.red1[SYSConst.medium1]); } else if (day.getDayOfWeek() == DateTimeConstants.SATURDAY || day.getDayOfWeek() == DateTimeConstants.SUNDAY) { cpDay.setBackground(SYSConst.red1[SYSConst.light3]); } else { cpDay.setBackground(SYSConst.orange1[SYSConst.light3]); } cpDay.setOpaque(true); cpDay.setHorizontalAlignment(SwingConstants.LEADING); cpDay.setStyle(CollapsiblePane.PLAIN_STYLE); cpDay.addCollapsiblePaneListener(new CollapsiblePaneAdapter() { @Override public void paneExpanded(CollapsiblePaneEvent collapsiblePaneEvent) { createContentPanel4Day(day, cpDay); btnAcknowledge.setEnabled(true); } @Override public void paneCollapsed(CollapsiblePaneEvent collapsiblePaneEvent) { btnAcknowledge.setEnabled(false); } }); btnAcknowledge.setEnabled(!cpDay.isCollapsed()); if (!cpDay.isCollapsed()) { createContentPanel4Day(day, cpDay); } return cpDay; }
From source file:org.eevolution.form.VCRP.java
public CategoryDataset createDataset(Timestamp start, MResource r) { //System.out.println("Create new data set"); GregorianCalendar gc1 = new GregorianCalendar(); gc1.setTimeInMillis(start.getTime()); gc1.clear(Calendar.MILLISECOND); gc1.clear(Calendar.SECOND);//from ww w . j a v a2 s . co m gc1.clear(Calendar.MINUTE); gc1.clear(Calendar.HOUR_OF_DAY); Timestamp date = start; String namecapacity = Msg.translate(Env.getCtx(), "Capacity"); System.out.println("\n Namecapacity :" + namecapacity); String nameload = Msg.translate(Env.getCtx(), "Load"); System.out.println("\n Nameload :" + nameload); String namesummary = Msg.translate(Env.getCtx(), "Summary"); System.out.println("\n Namesummary :" + namesummary); MResourceType t = new MResourceType(Env.getCtx(), r.getS_ResourceType_ID(), null); System.out.println("\n Resourcetype " + t); int days = 1; long hours = 0; if (t.isTimeSlot()) { hours = MMPCMRP.getHoursAvailable(t.getTimeSlotStart(), t.getTimeSlotEnd()); } else { //fjviejo e-evolution MachineQty if (r.getDailyCapacity().multiply(r.getMachineQty()).compareTo(Env.ZERO) != 0) hours = r.getDailyCapacity().multiply(r.getMachineQty()).longValue(); else //fjviejo e-evolution end hours = 24; } DefaultCategoryDataset dataset = new DefaultCategoryDataset(); // Long Hours = new Long(hours); int C_UOM_ID = DB.getSQLValue(null, "SELECT C_UOM_ID FROM M_Product WHERE S_Resource_ID = ? ", r.getS_Resource_ID()); MUOM uom = new MUOM(Env.getCtx(), C_UOM_ID, null); System.out.println("\n uom1 " + uom + "\n"); //System.out.println("um.isHour()"+ uom.isHour() ); if (!uom.isHour()) { System.out.println("\n uom2 " + uom + "\n"); return dataset; } System.out.println("\n Dataset " + dataset + "\n"); int summary = 0; //int cont = 1; DateFormat formatter = DateFormat.getDateInstance(); /* * Vit4B Modificado para que tome 28 dias y * * */ while (days < 29) { /* * VIT4B MODIFICACION PARA ACUMULADO DE DIAS * * * //System.out.println("Day Number" + days); String strday = formatter.format(date); //String day = new String(new Integer (date.getDate()).toString()); String day = new String(formatter.format(date)); //day = day.substring(0,5); int index = day.indexOf("/"); String str = day.substring(0,index); System.out.println("str: " + str + " index de / " + index); String str2 = day.substring(index+1,day.length()); System.out.println("str2 resto: " + str2); index = str2.indexOf("/"); System.out.println(index); String str3 = str2.substring(0,index); System.out.println("str3: " + str3 + " index de / " + index); String str4 = str2.substring(index+1,str2.length()); System.out.println(str4); System.out.println("dia: " + str); System.out.println("mes: " + str3); System.out.println("ao: " + str4); //day = str + str3; day = new String(str + str3); //day = day.substring(0,day.lastIndexOf("/")); //day =day.substring(0,3); //cont++; System.out.println("r.getS_Resource_ID()" + r.getS_Resource_ID()); System.out.println("Date: " + date + " day: " + day); int seconds = getLoad(r.getS_Resource_ID(),date ,date); Long Hours = new Long(hours); System.out.println("Summary "+ summary); System.out.println("Capacity "+ hours); System.out.println("Load "+ seconds); /* * * VIT4B MODIFICACION PARA ACUMULADO DE DIAS * * */ /* * ORIGINAL COMPIERE */ String day = new String(new Integer(date.getDate()).toString()); System.out.println("r.getS_Resource_ID()" + r.getS_Resource_ID()); System.out.println("Date:" + date); /* * VIT4B - Modificacin para calcular como se calcula el reporte CCRP * en funcion de la carga parcial * * */ int seconds = getLoad(r.getS_Resource_ID(), date, date); //BigDecimal value = calculateLoad(date, r, null); //int seconds = value.intValue(); Long Hours = new Long(hours); System.out.println("Summary " + summary); System.out.println("Load " + seconds); /* * FIN ORIGINAL COMPIERE * */ switch (gc1.get(Calendar.DAY_OF_WEEK)) { case Calendar.SUNDAY: days++; if (t.isOnSunday()) { //System.out.println("si Sunday"); //Msg.translate(Env.getCtx(), "OnSunday"); dataset.addValue(hours, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (seconds / 3600); //+ (Hours.intValue() - ((seconds / 3600))); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } else { //System.out.println("no Sunday"); //String day = Msg.translate(Env.getCtx(), "OnSunday") ; dataset.addValue(0, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } case Calendar.MONDAY: days++; if (t.isOnMonday()) { //System.out.println("si Monday"); //String day = Msg.translate(Env.getCtx(), "OnMonday") ; dataset.addValue(hours, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } else { //System.out.println("no Monday"); //String day = Msg.translate(Env.getCtx(), "OnMonday") ; dataset.addValue(0, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } case Calendar.TUESDAY: days++; if (t.isOnTuesday()) { //System.out.println("si TuesDay"); //String day = Msg.translate(Env.getCtx(), "OnTuesday"); dataset.addValue(hours, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } else { //System.out.println("no TuesDay"); //String day = Msg.translate(Env.getCtx(), "OnTuesday"); dataset.addValue(0, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } case Calendar.WEDNESDAY: days++; if (t.isOnWednesday()) { //String day = Msg.translate(Env.getCtx(), "OnWednesday"); dataset.addValue(hours, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } else { //String day = Msg.translate(Env.getCtx(), "OnWednesday"); dataset.addValue(0, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } case Calendar.THURSDAY: days++; if (t.isOnThursday()) { //String day = Msg.translate(Env.getCtx(), "OnThursday"); dataset.addValue(hours, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } else { //String day = Msg.translate(Env.getCtx(), "OnThursday"); dataset.addValue(0, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } case Calendar.FRIDAY: days++; if (t.isOnFriday()) { //String day = Msg.translate(Env.getCtx(), "OnFriday"); dataset.addValue(hours, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } else { //String day = Msg.translate(Env.getCtx(), "OnFriday"); dataset.addValue(0, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } case Calendar.SATURDAY: days++; if (t.isOnSaturday()) { //String day = Msg.translate(Env.getCtx(), "OnSaturday"); dataset.addValue(hours, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } else { //String day = Msg.translate(Env.getCtx(), "OnSaturday"); dataset.addValue(0, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } } } return dataset; }
From source file:org.hxzon.demo.jfreechart.CategoryDatasetDemo2.java
private static JFreeChart createGanttChart(CategoryDataset dataset) { CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel); DateAxis dateAxis = new DateAxis(valueAxisLabel); CategoryItemRenderer renderer = new GanttRenderer(); if (tooltips) { renderer.setBaseToolTipGenerator( new IntervalCategoryToolTipGenerator("{3} - {4}", DateFormat.getDateInstance())); }/*from w w w . j ava2 s .co m*/ if (urls) { renderer.setBaseItemURLGenerator(new StandardCategoryURLGenerator()); } CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, dateAxis, renderer); plot.setOrientation(PlotOrientation.HORIZONTAL); JFreeChart chart = new JFreeChart("Gantt Chart Demo 1", JFreeChart.DEFAULT_TITLE_FONT, plot, legend); chart.setBackgroundPaint(Color.white); GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64)); GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0)); GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(64, 0, 0)); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); renderer.setSeriesPaint(2, gp2); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); return chart; }
From source file:op.care.reports.PnlReport.java
private void reloadDisplay(final boolean lockmessageAfterwards) { /***/*from ww w . j av a 2 s . co m*/ * _ _ ____ _ _ * _ __ ___| | ___ __ _ __| | _ \(_)___ _ __ | | __ _ _ _ * | '__/ _ \ |/ _ \ / _` |/ _` | | | | / __| '_ \| |/ _` | | | | * | | | __/ | (_) | (_| | (_| | |_| | \__ \ |_) | | (_| | |_| | * |_| \___|_|\___/ \__,_|\__,_|____/|_|___/ .__/|_|\__,_|\__, | * |_| |___/ */ synchronized (contentmap) { SYSTools.clear(contentmap); } synchronized (cpMap) { SYSTools.clear(cpMap); } synchronized (linemap) { SYSTools.clear(linemap); } synchronized (valuecache) { SYSTools.clear(valuecache); } initPhase = true; OPDE.getMainframe().setBlocked(true); OPDE.getDisplayManager().setProgressBarMessage(new DisplayMessage(SYSTools.xx("misc.msg.wait"), -1, 100)); final long time = System.currentTimeMillis(); SwingWorker worker = new SwingWorker() { Date max = null; @Override protected Object doInBackground() throws Exception { GUITools.setResidentDisplay(resident); if (minmax == null) { minmax = NReportTools.getMinMax(resident); } holidays = Collections.synchronizedMap( SYSCalendar.getHolidays(minmax.getStart().getYear(), minmax.getEnd().getYear())); if (minmax != null) { max = minmax.getEnd().toDate(); LocalDate start = SYSCalendar.bom(minmax.getStart()).toLocalDate(); LocalDate end = resident.isActive() ? new LocalDate() : SYSCalendar.bom(minmax.getEnd()).toLocalDate(); int maxYears = Years.yearsBetween(start.toDateTimeAtStartOfDay(), end.toDateTimeAtStartOfDay()) .getYears(); int i = 0; for (int year = end.getYear(); year >= start.getYear(); year--) { OPDE.debug((System.currentTimeMillis() - time) + " ms"); i++; OPDE.getDisplayManager().setProgressBarMessage( new DisplayMessage(SYSTools.xx("misc.msg.wait"), i, maxYears)); createCP4Year(year, start, end); } OPDE.debug((System.currentTimeMillis() - time) + " ms1"); } return null; } @Override protected void done() { OPDE.debug((System.currentTimeMillis() - time) + " ms2"); expandTheLast2Weeks(); OPDE.debug((System.currentTimeMillis() - time) + " ms3"); buildPanel(); OPDE.debug((System.currentTimeMillis() - time) + " ms4"); initPhase = false; OPDE.getDisplayManager().setProgressBarMessage(null); OPDE.getMainframe().setBlocked(false); if (lockmessageAfterwards) OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage()); if (max != null) { OPDE.getDisplayManager().addSubMessage(new DisplayMessage( SYSTools.xx("misc.msg.lastEntry") + ": " + DateFormat.getDateInstance().format(max), 5)); } else { OPDE.getDisplayManager() .addSubMessage(new DisplayMessage(SYSTools.xx("misc.msg.noentryyet"), 5)); } } }; worker.execute(); }
From source file:com.evolveum.midpoint.web.component.prism.ContainerWrapper.java
private static String formatTime(XMLGregorianCalendar time) { DateFormat formatter = DateFormat.getDateInstance(); return formatter.format(time.toGregorianCalendar().getTime()); }