List of usage examples for java.text DateFormat LONG
int LONG
To view the source code for java.text DateFormat LONG.
Click Source Link
From source file:gov.opm.scrd.batchprocessing.jobs.BatchProcessingJob.java
/** * Audit the lock box import file error. * @param subject the error subject//from w ww. j a va2 s. c o m * @param description the error description */ private void auditError(String subject, String description) { AuditRecord record = new AuditRecord(); record.setUsername("Batch Process Module"); record.setDate(new Date()); record.setIpAddress("N/A"); record.setActionName("Lock Box Import Error"); List<AuditParameterRecord> list = new ArrayList<AuditParameterRecord>(); AuditParameterRecord param = new AuditParameterRecord(); param.setItemId(0L); param.setItemType("Lock Box Import"); param.setPropertyName("subject"); param.setPreviousValue("N/A"); param.setNewValue(subject); list.add(param); AuditParameterRecord param2 = new AuditParameterRecord(); param2.setItemId(0L); param2.setItemType("Lock Box Import"); param2.setPropertyName("error description"); param2.setPreviousValue("N/A"); param2.setNewValue(description.replace("@#$%EndingTime%$#@", DateFormat.getTimeInstance(DateFormat.LONG, Locale.US).format(new Date()))); list.add(param2); record.setParameters(list); persistEntity(record); }
From source file:gov.opm.scrd.batchprocessing.jobs.BatchProcessingJob.java
/** * Saves the process messages./*from www . j av a 2s .c o m*/ * @param procMessage the process message */ private void savePaymentStatusPrint(String procMessage) { PaymentStatementPrint psp = new PaymentStatementPrint(); psp.setDate(new Date()); psp.setMessage(procMessage.replace("@#$%EndingTime%$#@", DateFormat.getTimeInstance(DateFormat.LONG, Locale.US).format(new Date()))); persistEntity(psp); }
From source file:org.domainmath.gui.MainFrame.java
public void saveHistory(File file) { try {//from w w w. j av a 2 s .co m try (BufferedWriter r = new BufferedWriter(new FileWriter(file))) { DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, Locale.getDefault()); r.append("# Created by DomainMath IDE on " + formatter.format(new Date())); r.newLine(); histArea.write(r); r.close(); } } catch (Exception re) { JOptionPane.showMessageDialog(this, re.toString(), "Error", JOptionPane.ERROR_MESSAGE); } }
From source file:net.wastl.webmail.server.WebMailSession.java
private String formatDate(long date) { TimeZone tz = TimeZone.getDefault(); DateFormat df = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.DEFAULT, getLocale()); df.setTimeZone(tz);/*w w w. j a v a 2s.c o m*/ String now = df.format(new Date(date)); return now; }
From source file:org.etudes.component.app.melete.ModuleDB.java
public void copyModule(Module module, String courseId, String userId) throws MeleteException { ResourceLoader bundle = new ResourceLoader("melete_license"); try {/*from ww w . j a v a 2 s. c om*/ //get module and its sections Module copyMod = new Module(module); String firstName = UserDirectoryService.getCurrentUser().getFirstName(); String lastName = UserDirectoryService.getCurrentUser().getLastName(); DateFormat shortTime = DateFormat.getDateInstance(DateFormat.LONG); copyMod.setCreatedByFname(firstName); copyMod.setCreatedByLname(lastName); copyMod.setTitle(copyMod.getTitle() + " (" + bundle.getString("Copied") + " " + shortTime.format(new Date()) + " )"); ModuleShdates CopyModuleshowdates = new ModuleShdates((ModuleShdates) module.getModuleshdate()); // insert copy module with blank seq_xml and sections as null addModule(copyMod, CopyModuleshowdates, userId, courseId); String copyModSeqXml = module.getSeqXml(); //get sections List<Section> toCopySections = getSections(module.getModuleId().intValue()); if (toCopySections != null && toCopySections.size() > 0) { for (Section toCopySection : toCopySections) { // with title as copy of xxx and sectionResource Section copySection = new Section(toCopySection); copySection.setCreatedByFname(firstName); copySection.setCreatedByLname(lastName); copySection.setModule(copyMod); copySection.setTitle(copySection.getTitle() + " (" + bundle.getString("Copied") + " " + shortTime.format(new Date()) + " )"); //insert section Integer copySectionId = sectionDB.addSection(copyMod, copySection, false); copySection.setSectionId(copySectionId); //copySection.setModule(copyMod); if (toCopySection.getContentType() != null && !toCopySection.getContentType().equals("notype")) { // if section content type is composed than create a new copy if (toCopySection.getContentType().equals("typeEditor")) { String copyModCollId = meleteCHService.getCollectionId("typeEditor", copyMod.getModuleId()); String res_mime_type = meleteCHService.MIME_TYPE_EDITOR; ContentResource cr = meleteCHService .getResource(toCopySection.getSectionResource().getResource().getResourceId()); byte[] secContentData = cr.getContent(); boolean encodingFlag = true; String secResourceName = meleteCHService.getTypeEditorSectionName(copySectionId); String secResourceDescription = "compose content"; ResourcePropertiesEdit res = meleteCHService.fillInSectionResourceProperties( encodingFlag, secResourceName, secResourceDescription); String newResourceId = meleteCHService.addResourceItem(secResourceName, res_mime_type, copyModCollId, secContentData, res); MeleteResource copyMelResource = new MeleteResource( (MeleteResource) toCopySection.getSectionResource().getResource()); copyMelResource.setResourceId(newResourceId); sectionDB.insertMeleteResource(copySection, copyMelResource); } else if (toCopySection.getSectionResource() != null) { // insert section resource with same melete resource MeleteResource copyMr = (MeleteResource) toCopySection.getSectionResource() .getResource(); if (copyMr != null) sectionDB.insertSectionResource(copySection, copyMr); } } // replace with new copied section copyModSeqXml = copyModSeqXml.replace(toCopySection.getSectionId().toString(), copySectionId.toString()); } } // update module seq xml Module copyMod1 = getModule(copyMod.getModuleId()); copyMod1.setSeqXml(copyModSeqXml); updateModule(copyMod1); } catch (Exception ex) { ex.printStackTrace(); throw new MeleteException("copy_fail"); } }
From source file:net.sf.fspdfs.chartthemes.simple.SimpleChartTheme.java
protected void setAxisTickLabels(Axis axis, JRFont tickLabelFont, Paint tickLabelColor, String tickLabelMask, AxisSettings axisSettings) {//from ww w. ja v a2s . c o m boolean axisTickLabelsVisible = axisSettings.getTickLabelsVisible() == null || axisSettings.getTickLabelsVisible().booleanValue();//FIXMETHEME axis visibility should be dealt with above; axis.setTickLabelsVisible(axisTickLabelsVisible); if (axisTickLabelsVisible) { JRBaseFont font = new JRBaseFont(); JRFontUtil.copyNonNullOwnProperties(axisSettings.getTickLabelFont(), font); JRFontUtil.copyNonNullOwnProperties(tickLabelFont, font); font = new JRBaseFont(getChart(), font); axis.setTickLabelFont(JRFontUtil.getAwtFont(font, getLocale())); RectangleInsets tickLabelInsets = axisSettings.getTickLabelInsets(); if (tickLabelInsets != null) { axis.setTickLabelInsets(tickLabelInsets); } Paint tickLabelPaint = tickLabelColor != null ? tickLabelColor : axisSettings.getTickLabelPaint() != null ? axisSettings.getTickLabelPaint().getPaint() : null; if (tickLabelPaint != null) { axis.setTickLabelPaint(tickLabelPaint); } TimeZone timeZone = getChartContext().getTimeZone(); if (axis instanceof DateAxis && timeZone != null) { // used when no mask is set ((DateAxis) axis).setTimeZone(timeZone); } if (tickLabelMask != null) { if (axis instanceof NumberAxis) { NumberFormat fmt = NumberFormat.getInstance(); if (fmt instanceof DecimalFormat) ((DecimalFormat) fmt).applyPattern(tickLabelMask); ((NumberAxis) axis).setNumberFormatOverride(fmt); } else if (axis instanceof DateAxis) { DateFormat fmt; if (tickLabelMask.equals("SHORT") || tickLabelMask.equals("DateFormat.SHORT")) fmt = DateFormat.getDateInstance(DateFormat.SHORT); else if (tickLabelMask.equals("MEDIUM") || tickLabelMask.equals("DateFormat.MEDIUM")) fmt = DateFormat.getDateInstance(DateFormat.MEDIUM); else if (tickLabelMask.equals("LONG") || tickLabelMask.equals("DateFormat.LONG")) fmt = DateFormat.getDateInstance(DateFormat.LONG); else if (tickLabelMask.equals("FULL") || tickLabelMask.equals("DateFormat.FULL")) fmt = DateFormat.getDateInstance(DateFormat.FULL); else fmt = new SimpleDateFormat(tickLabelMask); // FIXME fmt cannot be null if (fmt != null) { if (timeZone != null) { fmt.setTimeZone(timeZone); } ((DateAxis) axis).setDateFormatOverride(fmt); } else ((DateAxis) axis).setDateFormatOverride( DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT)); } // ignore mask for other axis types. } } }
From source file:net.sf.fspdfs.chartthemes.spring.GenericChartTheme.java
protected void setAxisTickLabels(Axis axis, JRFont tickLabelFont, Paint tickLabelColor, String tickLabelMask, Integer baseFontSize) {//from w ww.java2s .c o m Boolean defaultAxisTickLabelsVisible = (Boolean) getDefaultValue(defaultAxisPropertiesMap, ChartThemesConstants.AXIS_TICK_LABELS_VISIBLE); if (defaultAxisTickLabelsVisible != null && defaultAxisTickLabelsVisible.booleanValue()) { Font themeTickLabelFont = getFont( (JRFont) getDefaultValue(defaultAxisPropertiesMap, ChartThemesConstants.AXIS_TICK_LABEL_FONT), tickLabelFont, baseFontSize); axis.setTickLabelFont(themeTickLabelFont); RectangleInsets defaultTickLabelInsets = (RectangleInsets) getDefaultValue(defaultAxisPropertiesMap, ChartThemesConstants.AXIS_TICK_LABEL_INSETS); if (defaultTickLabelInsets != null) { axis.setTickLabelInsets(defaultTickLabelInsets); } Paint tickLabelPaint = tickLabelColor != null ? tickLabelColor : (Paint) getDefaultValue(defaultAxisPropertiesMap, ChartThemesConstants.AXIS_TICK_LABEL_PAINT); if (tickLabelPaint != null) { axis.setTickLabelPaint(tickLabelPaint); } TimeZone timeZone = getChartContext().getTimeZone(); if (axis instanceof DateAxis && timeZone != null) { // used when no mask is set ((DateAxis) axis).setTimeZone(timeZone); } if (tickLabelMask != null) { if (axis instanceof NumberAxis) { NumberFormat fmt = NumberFormat.getInstance(); if (fmt instanceof DecimalFormat) ((DecimalFormat) fmt).applyPattern(tickLabelMask); ((NumberAxis) axis).setNumberFormatOverride(fmt); } else if (axis instanceof DateAxis) { DateFormat fmt; if (tickLabelMask.equals("SHORT") || tickLabelMask.equals("DateFormat.SHORT")) fmt = DateFormat.getDateInstance(DateFormat.SHORT); else if (tickLabelMask.equals("MEDIUM") || tickLabelMask.equals("DateFormat.MEDIUM")) fmt = DateFormat.getDateInstance(DateFormat.MEDIUM); else if (tickLabelMask.equals("LONG") || tickLabelMask.equals("DateFormat.LONG")) fmt = DateFormat.getDateInstance(DateFormat.LONG); else if (tickLabelMask.equals("FULL") || tickLabelMask.equals("DateFormat.FULL")) fmt = DateFormat.getDateInstance(DateFormat.FULL); else fmt = new SimpleDateFormat(tickLabelMask); // FIXME fmt cannot be null if (fmt != null) { if (timeZone != null) { fmt.setTimeZone(timeZone); } ((DateAxis) axis).setDateFormatOverride(fmt); } else ((DateAxis) axis).setDateFormatOverride( DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT)); } // ignore mask for other axis types. } } }
From source file:net.sf.jasperreports.chartthemes.simple.SimpleChartTheme.java
protected void setAxisTickLabels(Axis axis, JRFont tickLabelFont, Paint tickLabelColor, String tickLabelMask, AxisSettings axisSettings) {/* ww w. j a v a 2 s . com*/ boolean axisTickLabelsVisible = axisSettings.getTickLabelsVisible() == null || axisSettings.getTickLabelsVisible();//FIXMETHEME axis visibility should be dealt with above; axis.setTickLabelsVisible(axisTickLabelsVisible); if (axisTickLabelsVisible) { JRBaseFont font = new JRBaseFont(); FontUtil.copyNonNullOwnProperties(axisSettings.getTickLabelFont(), font); FontUtil.copyNonNullOwnProperties(tickLabelFont, font); font = new JRBaseFont(getChart(), font); axis.setTickLabelFont(getFontUtil().getAwtFont(font, getLocale())); RectangleInsets tickLabelInsets = axisSettings.getTickLabelInsets(); if (tickLabelInsets != null) { axis.setTickLabelInsets(tickLabelInsets); } Paint tickLabelPaint = tickLabelColor != null ? tickLabelColor : axisSettings.getTickLabelPaint() != null ? axisSettings.getTickLabelPaint().getPaint() : null; if (tickLabelPaint != null) { axis.setTickLabelPaint(tickLabelPaint); } TimeZone timeZone = getChartContext().getTimeZone(); if (axis instanceof DateAxis && timeZone != null) { // used when no mask is set ((DateAxis) axis).setTimeZone(timeZone); } if (tickLabelMask != null) { if (axis instanceof NumberAxis) { NumberFormat fmt = NumberFormat.getInstance(getLocale()); if (fmt instanceof DecimalFormat) ((DecimalFormat) fmt).applyPattern(tickLabelMask); ((NumberAxis) axis).setNumberFormatOverride(fmt); } else if (axis instanceof DateAxis) { DateFormat fmt; if (tickLabelMask.equals("SHORT") || tickLabelMask.equals("DateFormat.SHORT")) fmt = DateFormat.getDateInstance(DateFormat.SHORT, getLocale()); else if (tickLabelMask.equals("MEDIUM") || tickLabelMask.equals("DateFormat.MEDIUM")) fmt = DateFormat.getDateInstance(DateFormat.MEDIUM, getLocale()); else if (tickLabelMask.equals("LONG") || tickLabelMask.equals("DateFormat.LONG")) fmt = DateFormat.getDateInstance(DateFormat.LONG, getLocale()); else if (tickLabelMask.equals("FULL") || tickLabelMask.equals("DateFormat.FULL")) fmt = DateFormat.getDateInstance(DateFormat.FULL, getLocale()); else fmt = new SimpleDateFormat(tickLabelMask, getLocale()); // FIXME fmt cannot be null if (fmt != null) { if (timeZone != null) { fmt.setTimeZone(timeZone); } ((DateAxis) axis).setDateFormatOverride(fmt); } else ((DateAxis) axis).setDateFormatOverride( DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, getLocale())); } // ignore mask for other axis types. } } }
From source file:net.sf.jasperreports.chartthemes.spring.GenericChartTheme.java
protected void setAxisTickLabels(Axis axis, JRFont tickLabelFont, Paint tickLabelColor, String tickLabelMask, Integer baseFontSize) {/*w w w. ja v a 2s . co m*/ Boolean defaultAxisTickLabelsVisible = (Boolean) getDefaultValue(defaultAxisPropertiesMap, ChartThemesConstants.AXIS_TICK_LABELS_VISIBLE); if (defaultAxisTickLabelsVisible != null && defaultAxisTickLabelsVisible) { Font themeTickLabelFont = getFont( (JRFont) getDefaultValue(defaultAxisPropertiesMap, ChartThemesConstants.AXIS_TICK_LABEL_FONT), tickLabelFont, baseFontSize); axis.setTickLabelFont(themeTickLabelFont); RectangleInsets defaultTickLabelInsets = (RectangleInsets) getDefaultValue(defaultAxisPropertiesMap, ChartThemesConstants.AXIS_TICK_LABEL_INSETS); if (defaultTickLabelInsets != null) { axis.setTickLabelInsets(defaultTickLabelInsets); } Paint tickLabelPaint = tickLabelColor != null ? tickLabelColor : (Paint) getDefaultValue(defaultAxisPropertiesMap, ChartThemesConstants.AXIS_TICK_LABEL_PAINT); if (tickLabelPaint != null) { axis.setTickLabelPaint(tickLabelPaint); } TimeZone timeZone = getChartContext().getTimeZone(); if (axis instanceof DateAxis && timeZone != null) { // used when no mask is set ((DateAxis) axis).setTimeZone(timeZone); } if (tickLabelMask != null) { if (axis instanceof NumberAxis) { NumberFormat fmt = NumberFormat.getInstance(getLocale()); if (fmt instanceof DecimalFormat) ((DecimalFormat) fmt).applyPattern(tickLabelMask); ((NumberAxis) axis).setNumberFormatOverride(fmt); } else if (axis instanceof DateAxis) { DateFormat fmt; if (tickLabelMask.equals("SHORT") || tickLabelMask.equals("DateFormat.SHORT")) fmt = DateFormat.getDateInstance(DateFormat.SHORT, getLocale()); else if (tickLabelMask.equals("MEDIUM") || tickLabelMask.equals("DateFormat.MEDIUM")) fmt = DateFormat.getDateInstance(DateFormat.MEDIUM, getLocale()); else if (tickLabelMask.equals("LONG") || tickLabelMask.equals("DateFormat.LONG")) fmt = DateFormat.getDateInstance(DateFormat.LONG, getLocale()); else if (tickLabelMask.equals("FULL") || tickLabelMask.equals("DateFormat.FULL")) fmt = DateFormat.getDateInstance(DateFormat.FULL, getLocale()); else fmt = new SimpleDateFormat(tickLabelMask, getLocale()); // FIXME fmt cannot be null if (fmt != null) { if (timeZone != null) { fmt.setTimeZone(timeZone); } ((DateAxis) axis).setDateFormatOverride(fmt); } else ((DateAxis) axis).setDateFormatOverride( DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, getLocale())); } // ignore mask for other axis types. } } }
From source file:de.innovationgate.wga.server.api.WGA.java
/** * Returns an OpenWGA date format//from www . j av a 2 s.c o m * @param pattern The date format pattern * @param locale A locale to use for locale-dependent date parts. Specify null to let the current WebTML context choose the locale. * @throws WGException */ public DateFormat getDateFormat(String pattern, Locale locale) throws WGException { // Select language for language dependent date formats if (locale == null) { locale = chooseLocale(locale); } // Language Fallback(s) if (WGUtils.isEmpty(pattern)) { return DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, locale); } // For default patterns String lcPattern = pattern.toLowerCase(); if (lcPattern.endsWith("date") || lcPattern.endsWith("time")) { int patternLength; if (lcPattern.startsWith("short")) { patternLength = DateFormat.SHORT; } else if (lcPattern.startsWith("medium")) { patternLength = DateFormat.MEDIUM; } else if (lcPattern.startsWith("long")) { patternLength = DateFormat.LONG; } else { patternLength = DateFormat.FULL; } if (lcPattern.endsWith("datetime")) { return new TextualDateFormat(locale, DateFormat.getDateTimeInstance(patternLength, patternLength, locale)); } else if (lcPattern.endsWith("time")) { return new TextualDateFormat(locale, DateFormat.getTimeInstance(patternLength, locale)); } else { return new TextualDateFormat(locale, DateFormat.getDateInstance(patternLength, locale)); } } else if (lcPattern.equals("iso8601")) { return new ISO8601DateFormat(); } // For custom patterns SimpleDateFormat dateFormat = new SimpleDateFormat(pattern, locale); dateFormat.setLenient(false); return new TextualDateFormat(locale, dateFormat); }