List of usage examples for java.text DateFormat FULL
int FULL
To view the source code for java.text DateFormat FULL.
Click Source Link
From source file:net.sf.jasperreports.chartthemes.simple.SimpleChartTheme.java
protected void setAxisTickLabels(Axis axis, JRFont tickLabelFont, Paint tickLabelColor, String tickLabelMask, AxisSettings axisSettings) {/* w w w .ja va 2 s .c o m*/ 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) {//from w ww . j av a2 s .c om 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/*w w w .j ava2s . com*/ * @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); }
From source file:org.sakaiproject.calendar.tool.CalendarAction.java
/** * Build the context for showing day view *//*from ww w . j av a2s. co m*/ protected void buildDayContext(VelocityPortlet portlet, Context context, RunData runData, CalendarActionState state) { Calendar calendarObj = null; boolean allowed = false; MyDate dateObj1 = null; CalendarEventVector CalendarEventVectorObj = null; String peid = ((JetspeedRunData) runData).getJs_peid(); SessionState sstate = ((JetspeedRunData) runData).getPortletSessionState(peid); Time m_time = TimeService.newTime(); TimeBreakdown b = m_time.breakdownLocal(); int stateYear = b.getYear(); int stateMonth = b.getMonth(); int stateDay = b.getDay(); context.put("todayYear", Integer.valueOf(stateYear)); context.put("todayMonth", Integer.valueOf(stateMonth)); context.put("todayDay", Integer.valueOf(stateDay)); if ((sstate.getAttribute(STATE_YEAR) != null) && (sstate.getAttribute(STATE_MONTH) != null) && (sstate.getAttribute(STATE_DAY) != null)) { stateYear = ((Integer) sstate.getAttribute(STATE_YEAR)).intValue(); stateMonth = ((Integer) sstate.getAttribute(STATE_MONTH)).intValue(); stateDay = ((Integer) sstate.getAttribute(STATE_DAY)).intValue(); } CalendarUtil calObj = new CalendarUtil(); calObj.setDay(stateYear, stateMonth, stateDay); // new objects of myYear, myMonth, myDay, myWeek classes dateObj1 = new MyDate(); dateObj1.setTodayDate(calObj.getMonthInteger(), calObj.getDayOfMonth(), calObj.getYear()); int year = dateObj1.getYear(); int month = dateObj1.getMonth(); int day = dateObj1.getDay(); Vector eventVector = new Vector(); String calId = state.getPrimaryCalendarReference(); if (CalendarService.allowGetCalendar(calId) == false) { context.put(ALERT_MSG_KEY, rb.getString("java.alert.younotallow")); return; } else { try { calendarObj = CalendarService.getCalendar(calId); allowed = calendarObj.allowAddEvent(); CalendarEventVectorObj = CalendarService.getEvents( getCalendarReferenceList(portlet, state.getPrimaryCalendarReference(), isOnWorkspaceTab()), getDayTimeRange(year, month, day)); String currentPage = state.getCurrentPage(); // if coming from clicking the the day number in month view, year view or list view // select the time slot first, go to the slot containing earliest event on that day if (state.getPrevState() != null) { if ((state.getPrevState()).equalsIgnoreCase("list") || (state.getPrevState()).equalsIgnoreCase("month") || (state.getPrevState()).equalsIgnoreCase("year")) { CalendarEventVector vec = null; Time timeObj = TimeService.newTimeLocal(year, month, day, FIRST_PAGE_START_HOUR, 00, 00, 000); Time timeObj2 = TimeService.newTimeLocal(year, month, day, 7, 59, 59, 000); TimeRange timeRangeObj = TimeService.newTimeRange(timeObj, timeObj2); vec = CalendarService.getEvents(getCalendarReferenceList(portlet, state.getPrimaryCalendarReference(), isOnWorkspaceTab()), timeRangeObj); if (vec.size() > 0) currentPage = "first"; else { timeObj = TimeService.newTimeLocal(year, month, day, SECOND_PAGE_START_HOUR, 00, 00, 000); timeObj2 = TimeService.newTimeLocal(year, month, day, 17, 59, 59, 000); timeRangeObj = TimeService.newTimeRange(timeObj, timeObj2); vec = CalendarService.getEvents(getCalendarReferenceList(portlet, state.getPrimaryCalendarReference(), isOnWorkspaceTab()), timeRangeObj); if (vec.size() > 0) currentPage = "second"; else { timeObj = TimeService.newTimeLocal(year, month, day, THIRD_PAGE_START_HOUR, 00, 00, 000); timeObj2 = TimeService.newTimeLocal(year, month, day, 23, 59, 59, 000); timeRangeObj = TimeService.newTimeRange(timeObj, timeObj2); vec = CalendarService.getEvents(getCalendarReferenceList(portlet, state.getPrimaryCalendarReference(), isOnWorkspaceTab()), timeRangeObj); if (vec.size() > 0) currentPage = "third"; else currentPage = "second"; } } state.setCurrentPage(currentPage); } } if (currentPage.equals("third")) { eventVector = getNewEvents(year, month, day, state, runData, THIRD_PAGE_START_HOUR, 19, context, CalendarEventVectorObj); } else if (currentPage.equals("second")) { eventVector = getNewEvents(year, month, day, state, runData, SECOND_PAGE_START_HOUR, 19, context, CalendarEventVectorObj); } else { eventVector = getNewEvents(year, month, day, state, runData, FIRST_PAGE_START_HOUR, 19, context, CalendarEventVectorObj); } dateObj1.setEventBerDay(eventVector); } catch (IdUnusedException e) { context.put(ALERT_MSG_KEY, rb.getString("java.alert.therenoactv")); M_log.debug(".buildDayContext(): " + e); return; } catch (PermissionException e) { context.put(ALERT_MSG_KEY, rb.getString("java.alert.younotperm")); M_log.debug(".buildDayContext(): " + e); return; } } context.put("nameOfMonth", calendarUtilGetMonth(calObj.getMonthInteger())); context.put("monthInt", Integer.valueOf(calObj.getMonthInteger())); context.put("firstpage", "true"); context.put("secondpage", "false"); context.put("page", state.getCurrentPage()); context.put("date", dateObj1); context.put("helper", new Helper()); context.put("calObj", calObj); context.put("tlang", rb); context.put("config", configProps); state.setState("day"); context.put("message", state.getState()); DateFormat formatter = DateFormat.getDateInstance(DateFormat.FULL, new ResourceLoader().getLocale()); try { context.put("today", formatter.format(calObj.getTime())); } catch (Exception e) { context.put("today", calObj.getTodayDate()); } state.setPrevState(""); buildMenu(portlet, context, runData, state, CalendarPermissions.allowCreateEvents(state.getPrimaryCalendarReference(), state.getSelectedCalendarReference()), CalendarPermissions.allowDeleteEvent(state.getPrimaryCalendarReference(), state.getSelectedCalendarReference(), state.getCalendarEventId()), CalendarPermissions.allowReviseEvents(state.getPrimaryCalendarReference(), state.getSelectedCalendarReference(), state.getCalendarEventId()), CalendarPermissions.allowMergeCalendars(state.getPrimaryCalendarReference()), CalendarPermissions.allowModifyCalendarProperties(state.getPrimaryCalendarReference()), CalendarPermissions.allowImport(state.getPrimaryCalendarReference()), CalendarPermissions.allowSubscribe(state.getPrimaryCalendarReference()), CalendarPermissions.allowSubscribeThis(state.getPrimaryCalendarReference())); context.put("permissionallowed", Boolean.valueOf(allowed)); context.put("tlang", rb); context.put("config", configProps); context.put("selectedView", rb.getString("java.byday")); context.put("dayName", calendarUtilGetDay(calObj.getDay_Of_Week(true))); }
From source file:org.sakaiproject.calendar.tool.CalendarAction.java
/** * Build the context for showing week view *///w w w .j a v a 2s. c o m protected void buildWeekContext(VelocityPortlet portlet, Context context, RunData runData, CalendarActionState state) { Calendar calendarObj = null; //Time st,et = null; //CalendarUtil calObj= null; MyYear yearObj = null; MyMonth monthObj1 = null; MyWeek weekObj = null; MyDay dayObj = null; MyDate dateObj1, dateObj2 = null; int dayofweek = 0; // new objects of myYear, myMonth, myDay, myWeek classes yearObj = new MyYear(); monthObj1 = new MyMonth(); weekObj = new MyWeek(); dayObj = new MyDay(); dateObj1 = new MyDate(); CalendarEventVector CalendarEventVectorObj = null; //calObj = state.getCalObj(); String peid = ((JetspeedRunData) runData).getJs_peid(); SessionState sstate = ((JetspeedRunData) runData).getPortletSessionState(peid); Time m_time = TimeService.newTime(); TimeBreakdown b = m_time.breakdownLocal(); int stateYear = b.getYear(); int stateMonth = b.getMonth(); int stateDay = b.getDay(); if ((sstate.getAttribute(STATE_YEAR) != null) && (sstate.getAttribute(STATE_MONTH) != null) && (sstate.getAttribute(STATE_DAY) != null)) { stateYear = ((Integer) sstate.getAttribute(STATE_YEAR)).intValue(); stateMonth = ((Integer) sstate.getAttribute(STATE_MONTH)).intValue(); stateDay = ((Integer) sstate.getAttribute(STATE_DAY)).intValue(); } CalendarUtil calObj = new CalendarUtil(); calObj.setDay(stateYear, stateMonth, stateDay); int iii = 0; dateObj1.setTodayDate(calObj.getMonthInteger(), calObj.getDayOfMonth(), calObj.getYear()); yearObj.setYear(calObj.getYear()); monthObj1.setMonth(calObj.getMonthInteger()); dayObj.setDay(calObj.getDayOfMonth()); String calId = state.getPrimaryCalendarReference(); // this loop will move the calendar to the begining of the week if (CalendarService.allowGetCalendar(calId) == false) { context.put(ALERT_MSG_KEY, rb.getString("java.alert.younotallow")); return; } else { try { calendarObj = CalendarService.getCalendar(calId); } catch (IdUnusedException e) { try { CalendarService.commitCalendar(CalendarService.addCalendar(calId)); calendarObj = CalendarService.getCalendar(calId); } catch (Exception err) { context.put(ALERT_MSG_KEY, rb.getString("java.alert.therenoactv")); M_log.debug(".buildWeekContext(): " + err); return; } } catch (PermissionException e) { context.put(ALERT_MSG_KEY, rb.getString("java.alert.younotperm")); M_log.debug(".buildWeekContext(): " + e); return; } } if (calendarObj.allowGetEvents() == true) { CalendarEventVectorObj = CalendarService.getEvents( getCalendarReferenceList(portlet, state.getPrimaryCalendarReference(), isOnWorkspaceTab()), getWeekTimeRange(calObj)); } else { CalendarEventVectorObj = new CalendarEventVector(); } calObj.setDay(dateObj1.getYear(), dateObj1.getMonth(), dateObj1.getDay()); dayofweek = calObj.getDay_Of_Week(true); calObj.setPrevDate(dayofweek - 1); dayofweek = calObj.getDay_Of_Week(true); Time[] pageStartTime = new Time[7]; Time[] pageEndTime = new Time[7]; for (int i = 7; i >= dayofweek; i--) { Vector eventVector = new Vector(); Vector eventVector1; dateObj2 = new MyDate(); dateObj2.setTodayDate(calObj.getMonthInteger(), calObj.getDayOfMonth(), calObj.getYear()); dateObj2.setDayName(calendarUtilGetDay(calObj.getDay_Of_Week(true))); dateObj2.setNameOfMonth(calendarUtilGetMonth(calObj.getMonthInteger())); if (calObj.getDayOfMonth() == dayObj.getDay()) dateObj2.setFlag(1); if (state.getCurrentPage().equals("third")) { eventVector1 = new Vector(); // JS -- the third page starts at 2PM(14 o'clock), and lasts 20 half-hour eventVector = getNewEvents(calObj.getYear(), calObj.getMonthInteger(), calObj.getDayOfMonth(), state, runData, THIRD_PAGE_START_HOUR, 19, context, CalendarEventVectorObj); for (int index = 0; index < eventVector1.size(); index++) { eventVector.add(eventVector.size(), eventVector1.get(index)); } // Reminder: weekview vm is using 0..6 pageStartTime[i - 1] = TimeService.newTimeLocal(calObj.getYear(), calObj.getMonthInteger(), calObj.getDayOfMonth(), THIRD_PAGE_START_HOUR, 0, 0, 0); pageEndTime[i - 1] = TimeService.newTimeLocal(calObj.getYear(), calObj.getMonthInteger(), calObj.getDayOfMonth(), 23, 59, 0, 0); } else if (state.getCurrentPage().equals("second")) { eventVector = getNewEvents(calObj.getYear(), calObj.getMonthInteger(), calObj.getDayOfMonth(), state, runData, SECOND_PAGE_START_HOUR, 19, context, CalendarEventVectorObj); // Reminder: weekview vm is using 0..6 pageStartTime[i - 1] = TimeService.newTimeLocal(calObj.getYear(), calObj.getMonthInteger(), calObj.getDayOfMonth(), SECOND_PAGE_START_HOUR, 0, 0, 0); pageEndTime[i - 1] = TimeService.newTimeLocal(calObj.getYear(), calObj.getMonthInteger(), calObj.getDayOfMonth(), 17, 59, 0, 0); } else { eventVector1 = new Vector(); // JS -- the first page starts at 12AM(0 o'clock), and lasts 20 half-hour eventVector1 = getNewEvents(calObj.getYear(), calObj.getMonthInteger(), calObj.getDayOfMonth(), state, runData, FIRST_PAGE_START_HOUR, 19, context, CalendarEventVectorObj); for (int index = 0; index < eventVector1.size(); index++) { eventVector.insertElementAt(eventVector1.get(index), index); } // Reminder: weekview vm is using 0..6 pageStartTime[i - 1] = TimeService.newTimeLocal(calObj.getYear(), calObj.getMonthInteger(), calObj.getDayOfMonth(), 0, 0, 0, 0); pageEndTime[i - 1] = TimeService.newTimeLocal(calObj.getYear(), calObj.getMonthInteger(), calObj.getDayOfMonth(), 9, 59, 0, 0); } dateObj2.setEventBerWeek(eventVector); weekObj.setWeek(7 - i, dateObj2); // the purpose of this if condition is to check if we reached day 7 if yes do not // call next day. if (i > dayofweek) calObj.nextDate(); } calObj.setDay(yearObj.getYear(), monthObj1.getMonth(), dayObj.getDay()); context.put("week", weekObj); context.put("helper", new Helper()); context.put("date", dateObj1); context.put("page", state.getCurrentPage()); state.setState("week"); context.put("tlang", rb); context.put("config", configProps); context.put("message", state.getState()); DateFormat formatter = DateFormat.getDateInstance(DateFormat.FULL, new ResourceLoader().getLocale()); formatter.setTimeZone(TimeService.getLocalTimeZone()); try { context.put("beginWeek", formatter.format(calObj.getPrevTime(calObj.getDay_Of_Week(true) - 1))); } catch (Exception e) { context.put("beginWeek", calObj.getTodayDate()); } try { calObj.setNextWeek(); context.put("endWeek", formatter.format(calObj.getPrevTime(1))); } catch (Exception e) { context.put("endWeek", calObj.getTodayDate()); } buildMenu(portlet, context, runData, state, CalendarPermissions.allowCreateEvents(state.getPrimaryCalendarReference(), state.getSelectedCalendarReference()), CalendarPermissions.allowDeleteEvent(state.getPrimaryCalendarReference(), state.getSelectedCalendarReference(), state.getCalendarEventId()), CalendarPermissions.allowReviseEvents(state.getPrimaryCalendarReference(), state.getSelectedCalendarReference(), state.getCalendarEventId()), CalendarPermissions.allowMergeCalendars(state.getPrimaryCalendarReference()), CalendarPermissions.allowModifyCalendarProperties(state.getPrimaryCalendarReference()), CalendarPermissions.allowImport(state.getPrimaryCalendarReference()), CalendarPermissions.allowSubscribe(state.getPrimaryCalendarReference()), CalendarPermissions.allowSubscribeThis(state.getPrimaryCalendarReference())); calObj.setDay(yearObj.getYear(), monthObj1.getMonth(), dayObj.getDay()); context.put("realDate", TimeService.newTime()); context.put("tlang", rb); context.put("config", configProps); Vector vec = new Vector(); context.put("vec", vec); Vector conflictVec = new Vector(); context.put("conflictVec", conflictVec); Vector calVec = new Vector(); context.put("calVec", calVec); HashMap hm = new HashMap(); context.put("hm", hm); Integer intObj = Integer.valueOf(0); context.put("intObj", intObj); context.put("pageStartTime", pageStartTime); context.put("pageEndTime", pageEndTime); context.put("selectedView", rb.getString("java.byweek")); context.put("dayOfWeekNames", calObj.getCalendarDaysOfWeekNames(false)); }