List of usage examples for java.time.format TextStyle FULL
TextStyle FULL
To view the source code for java.time.format TextStyle FULL.
Click Source Link
From source file:Main.java
public static void main(String[] args) { ZoneId z = ZoneId.systemDefault(); System.out.println(z.getDisplayName(TextStyle.FULL, Locale.CANADA)); }
From source file:Main.java
public static void main(String[] args) { LocalDate localDate = LocalDate.of(2014, Month.JUNE, 21); DayOfWeek dayOfWeek = DayOfWeek.from(localDate); System.out.println(dayOfWeek.getDisplayName(TextStyle.FULL, Locale.CANADA)); System.out.println(dayOfWeek.getDisplayName(TextStyle.SHORT, Locale.CANADA)); System.out.println(dayOfWeek.getDisplayName(TextStyle.NARROW, Locale.CANADA)); }
From source file:Main.java
public static void main(String[] args) { LocalDate date = LocalDate.of(2014, Month.FEBRUARY, 15); // 2014-02-15 DayOfWeek dayOfWeek = date.getDayOfWeek(); // SATURDAY dayOfWeek = DayOfWeek.FRIDAY; Locale locale = Locale.getDefault(); System.out.println(dayOfWeek.getDisplayName(TextStyle.FULL, locale)); // Friday System.out.println(dayOfWeek.getDisplayName(TextStyle.NARROW, locale)); // F System.out.println(dayOfWeek.getDisplayName(TextStyle.SHORT, locale)); // Fri }
From source file:Main.java
public static void main(String[] args) { LocalDate date = LocalDate.of(2014, 2, 15); // 2014-02-15 // ISO-8601 standard // the day-of-week to represent, from 1 (Monday) to 7 (Sunday) DayOfWeek dayOfWeek = date.getDayOfWeek(); System.out.println(dayOfWeek); // SATURDAY System.out.println(DayOfWeek.of(3)); // WEDNESDAY System.out.println(dayOfWeek.getValue()); // 6 System.out.println(dayOfWeek.name()); // SATURDAY System.out.println(date.getDayOfMonth()); // 15 System.out.println(date.atStartOfDay()); // 2014-02-15 00:00 System.out.println("DayOfWeek"); dayOfWeek = DayOfWeek.FRIDAY; Locale locale = Locale.getDefault(); System.out.println(dayOfWeek.getDisplayName(TextStyle.FULL, locale)); // Friday System.out.println(dayOfWeek.getDisplayName(TextStyle.NARROW, locale)); // F System.out.println(dayOfWeek.getDisplayName(TextStyle.SHORT, locale)); // Fri }
From source file:org.efaps.esjp.common.uiform.Field_Base.java
/** * @param _parameter Parameter as passed from the eFaps API * @return Return containing Html Snipplet * @throws EFapsException on error//from w w w. ja v a 2 s. c o m */ public Return getOptionList4DateTime(final Parameter _parameter) throws EFapsException { final List<DropDownPosition> positions = new ArrayList<>(); final String dateFieldType = getProperty(_parameter, "DateFieldType", "YEAR"); switch (dateFieldType) { case "MONTH": for (final Month month : Month.values()) { final DropDownPosition pos = getDropDownPosition(_parameter, month.getValue(), month.getDisplayName(TextStyle.FULL, Context.getThreadContext().getLocale())); pos.setSelected(month.getValue() == new DateTime().getMonthOfYear()); positions.add(pos); } break; case "YEAR": default: final String fromStr = getProperty(_parameter, "From", "-10"); final String toStr = getProperty(_parameter, "To", "+10"); LocalDate start; if (StringUtils.isNumeric(fromStr)) { start = LocalDate.of(Integer.parseInt(fromStr), 1, 1); } else { start = LocalDate.now().plusYears(Integer.parseInt(fromStr)); } final LocalDate end; if (StringUtils.isNumeric(toStr)) { end = LocalDate.of(Integer.parseInt(toStr), 1, 1); } else { end = LocalDate.now().plusYears(Integer.parseInt(toStr)); } while (start.isBefore(end)) { final DropDownPosition pos = getDropDownPosition(_parameter, start.getYear(), start.getYear()); pos.setSelected(start.getYear() == new DateTime().getYear()); positions.add(pos); start = start.plusYears(1); } break; } final Return ret = new Return(); ret.put(ReturnValues.VALUES, positions); return ret; }
From source file:org.geoname.parser.TimeZoneDisplay.java
public TimeZoneDisplay(final ZoneId zoneId) { if (zoneId == null) { throw new IllegalArgumentException("Cannot use null time zone"); }/* w w w. ja v a 2 s . c o m*/ timeZoneId = zoneId.getId(); timeZoneDisplayName = zoneId.getDisplayName(TextStyle.FULL, Locale.getDefault()); description = createDescription(); }
From source file:org.geoserver.taskmanager.web.panel.BatchesPanel.java
private String formatFrequency(String frequency) { if (frequency == null) { return null; }/*from w w w . j a va 2s . c om*/ Matcher matcher = FrequencyUtil.DAILY_PATTERN.matcher(frequency); if (matcher.matches()) { int minutes = Integer.parseInt(matcher.group(1)); int hour = Integer.parseInt(matcher.group(2)); if (minutes <= 60 && hour < 24) { return new ParamResourceModel("Daily", this).getString() + ", " + String.format("%02d", hour) + ":" + String.format("%02d", minutes); } } else { matcher = FrequencyUtil.WEEKLY_PATTERN.matcher(frequency); if (matcher.matches()) { int minutes = Integer.parseInt(matcher.group(1)); int hour = Integer.parseInt(matcher.group(2)); DayOfWeek day = FrequencyUtil.findDayOfWeek(matcher.group(3)); if (minutes <= 60 && hour < 24 && day != null) { return new ParamResourceModel("Weekly", this).getString() + ", " + day.getDisplayName(TextStyle.FULL, getLocale()) + ", " + String.format("%02d", hour) + ":" + String.format("%02d", minutes); } } else { matcher = FrequencyUtil.MONTHLY_PATTERN.matcher(frequency); if (matcher.matches()) { int minutes = Integer.parseInt(matcher.group(1)); int hour = Integer.parseInt(matcher.group(2)); int day = Integer.parseInt(matcher.group(3)); if (minutes <= 60 && hour < 24 && day > 0 && day <= 28) { return new ParamResourceModel("Monthly", this).getString() + ", " + new ParamResourceModel("Day", this).getString() + " " + day + ", " + String.format("%02d", hour) + ":" + String.format("%02d", minutes); } } } } return new ParamResourceModel("Custom", this).getString() + ", " + frequency; }
From source file:org.sakaiproject.sitestats.tool.wicket.pages.UserActivityPage.java
@Override protected void onInitialize() { super.onInitialize(); Form form = new Form("form"); add(form);/*from w ww . ja v a 2 s . c o m*/ add(new Menus("menu", siteId)); lastJobRunContainer = new WebMarkupContainer("lastJobRunContainer"); lastJobRunContainer.setOutputMarkupId(true); add(lastJobRunContainer); lastJobRunContainer.add(new LastJobRun("lastJobRun", siteId)); IChoiceRenderer<DisplayUser> userChoiceRenderer = new ChoiceRenderer<DisplayUser>() { @Override public Object getDisplayValue(DisplayUser user) { // Short circuit if user is blank if (StringUtils.isBlank(user.userId)) { return new ResourceModel("user_unknown").getObject(); } // String representation of 'select user' option if (ReportManager.WHO_NONE.equals(user.userId)) { return new ResourceModel("de_select_user").getObject(); } return user.display; } @Override public String getIdValue(DisplayUser user, int index) { return user.userId; } }; DropDownChoice<DisplayUser> userFilter = new DropDownChoice<>("userFilter", new PropertyModel<>(this, "displayUser"), new LoadableDisplayUserListModel(siteId), userChoiceRenderer); userFilter.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { if (ReportManager.WHO_NONE.equals(displayUser.userId)) { searchButton.setEnabled(false); target.add(searchButton); } else { searchButton.setEnabled(true); target.add(searchButton); } } }); userFilter.setLabel(new ResourceModel("de_userFilter")); form.add(new SimpleFormComponentLabel("userFilterLabel", userFilter)); form.add(userFilter); IChoiceRenderer<String> toolChoiceRenderer = new ChoiceRenderer<String>() { @Override public Object getDisplayValue(String toolId) { return Locator.getFacade().getEventRegistryService().getToolName(toolId); } @Override public String getIdValue(String toolId, int index) { return toolId; } }; DropDownChoice<String> eventFilterByTool = new DropDownChoice<>("eventFilter", new PropertyModel<>(this, "tool"), new LoadableToolIdListModel(siteId), toolChoiceRenderer); eventFilterByTool.setLabel(new ResourceModel("de_eventFilter")); form.add(new SimpleFormComponentLabel("eventFilterLabel", eventFilterByTool)); form.add(eventFilterByTool); ZoneId tz = Locator.getFacade().getUserTimeService().getLocalTimeZone().toZoneId(); startDate = ZonedDateTime.now(tz).truncatedTo(ChronoUnit.DAYS); SakaiDateTimeField startDateField = new SakaiDateTimeField("startDate", new PropertyModel<>(this, "startDate"), tz); startDateField.setLabel(new ResourceModel("de_dateRangeFrom")); form.add(new SimpleFormComponentLabel("startDateLabel", startDateField)); form.add(startDateField); endDate = startDate.plusDays(1); SakaiDateTimeField endDateField = new SakaiDateTimeField("endDate", new PropertyModel<>(this, "endDate"), tz); endDateField.setLabel(new ResourceModel("de_dateRangeTo")); form.add(new SimpleFormComponentLabel("endDateLabel", endDateField)); form.add(endDateField); String zoneName = startDate.getZone().getDisplayName(TextStyle.FULL, getSession().getLocale()); StringResourceModel legendModel = new StringResourceModel("de_dateRange", getPage(), null, new Object[] { zoneName }); form.add(new Label("dateRangeLegend", legendModel)); final UserTrackingResultsPanel resultsPanel = new UserTrackingResultsPanel("results", TrackingParams.EMPTY_PARAMS); resultsPanel.setOutputMarkupPlaceholderTag(true); resultsPanel.setVisible(false); add(resultsPanel); searchButton = new SakaiAjaxButton("search", form) { @Override public void onSubmit(AjaxRequestTarget target, Form form) { // run search PrefsData pd = Locator.getFacade().getStatsManager().getPreferences(siteId, false); TrackingParams params = new TrackingParams(siteId, Tools.getEventsForToolFilter(tool, siteId, pd, true), Collections.singletonList(displayUser.userId), startDate.toInstant(), endDate.toInstant()); resultsPanel.setTrackingParams(params); resultsPanel.setVisible(true); target.add(resultsPanel); lastJobRunContainer.replace(new LastJobRun("lastJobRun", siteId)); target.add(lastJobRunContainer); Locator.getFacade().getStatsManager().logEvent(new UserId(user), StatsManager.LOG_ACTION_TRACK, siteId, false); } }; searchButton.setEnabled(false); form.add(searchButton); }
From source file:rapture.dp.invocable.calendar.steps.CalendarLookupStep.java
@Override public String invoke(CallingContext ctx) { DecisionApi decision = Kernel.getDecision(); try {//from w w w .ja v a 2 s .co m decision.setContextLiteral(ctx, getWorkerURI(), "STEPNAME", getStepName()); String dateStr = StringUtils.stripToNull(decision.getContextValue(ctx, getWorkerURI(), "DATE")); String calendar = StringUtils.stripToNull(decision.getContextValue(ctx, getWorkerURI(), "CALENDAR")); String translator = StringUtils .stripToNull(decision.getContextValue(ctx, getWorkerURI(), "TRANSLATOR")); if (translator == null) translator = StringUtils .stripToNull(decision.getContextValue(ctx, getWorkerURI(), "DEFAULT_TRANSLATOR")); LocalDate date = (dateStr == null) ? LocalDate.now() : LocalDate.parse(dateStr); // Translate the date to a name - eg Good Friday, Yom Kippur, Thanksgiving // Expected format is a map of dates (with or without years) to names or lists of names // Example: // { // "31Dec" : ["New Tear's Eve", "Hogmanay"] , // "05Sep2016" : "Labor Day", // "04Sep2017" : "Labor Day" // "2015-01-01" : "New Year's Day" // } Map<String, Object> calendarTable = new HashMap<>(); if (calendar != null) { String calendarJson = StringUtils.stripToNull(Kernel.getDoc().getDoc(ctx, calendar)); if (calendarJson != null) { calendarTable = JacksonUtil.getMapFromJson(calendarJson); } } // Translate the date to a name - eg Good Friday, Yom Kippur, Thanksgiving Map<String, Object> translationTable = new HashMap<>(); if (translator != null) { String translationJson = StringUtils.stripToNull(Kernel.getDoc().getDoc(ctx, translator)); if (translationJson != null) { translationTable = JacksonUtil.getMapFromJson(translationJson); } } List<String> lookup = new ArrayList<>(); String languageTag = StringUtils.stripToNull(decision.getContextValue(ctx, getWorkerURI(), "LOCALE")); Locale locale = (languageTag == null) ? Locale.getDefault() : Locale.forLanguageTag(languageTag); for (DateTimeFormatter formatter : ImmutableList.of(DateTimeFormatter.ISO_LOCAL_DATE, DateTimeFormatter.ofPattern("ddMMMuuuu", locale), DateTimeFormatter.ofPattern("ddMMM", locale), DateTimeFormatter.ofPattern("MMMdduuuu", locale), DateTimeFormatter.ofPattern("MMMdd", locale), DateTimeFormatter.ofPattern("uuuuMMMdd", locale))) { String formattedDate = date.format(formatter); Object transList = translationTable.get(formattedDate); if (transList != null) { if (transList instanceof Iterable) { for (Object o : (Iterable) transList) { lookup.add(o.toString()); } } else lookup.add(transList.toString()); } lookup.add(formattedDate); } lookup.add(DayOfWeek.from(date).getDisplayName(TextStyle.FULL, locale)); decision.setContextLiteral(ctx, getWorkerURI(), "DATE_TRANSLATIONS", JacksonUtil.jsonFromObject(lookup)); // Calendar table defines the priority. getMapFromJson returns a LinkedHashMap so order is preserved. for (Entry<String, Object> calEntry : calendarTable.entrySet()) { if (lookup.contains(calEntry.getKey())) { decision.setContextLiteral(ctx, getWorkerURI(), "CALENDAR_LOOKUP_ENTRY", JacksonUtil.jsonFromObject(calEntry)); decision.writeWorkflowAuditEntry(ctx, getWorkerURI(), calEntry.getKey() + " matched as " + calEntry.getValue().toString(), false); return calEntry.getValue().toString(); } } decision.writeWorkflowAuditEntry(ctx, getWorkerURI(), getStepName() + ": No matches for " + DateTimeFormatter.ISO_LOCAL_DATE.format(date) + " found in calendar", false); return getNextTransition(); } catch (Exception e) { decision.setContextLiteral(ctx, getWorkerURI(), getStepName(), "Unable to access the calendar : " + e.getLocalizedMessage()); decision.setContextLiteral(ctx, getWorkerURI(), getStepName() + "Error", ExceptionToString.summary(e)); decision.writeWorkflowAuditEntry(ctx, getWorkerURI(), "Problem in " + getStepName() + ": " + ExceptionToString.getRootCause(e).getLocalizedMessage(), true); return getErrorTransition(); } }
From source file:rapture.dp.invocable.calendar.steps.GetDayOfWeekStep.java
@Override public String invoke(CallingContext ctx) { DecisionApi decision = Kernel.getDecision(); try {//from ww w . j av a 2 s .com decision.setContextLiteral(ctx, getWorkerURI(), "STEPNAME", getStepName()); String dateStr = StringUtils.stripToNull(decision.getContextValue(ctx, getWorkerURI(), "DATE")); String languageTag = StringUtils.stripToNull(decision.getContextValue(ctx, getWorkerURI(), "LOCALE")); LocalDateTime date = (dateStr == null) ? LocalDateTime.now() : LocalDateTime.parse(dateStr); Locale locale = (languageTag == null) ? Locale.getDefault() : Locale.forLanguageTag(languageTag); String day = DayOfWeek.from(date).getDisplayName(TextStyle.FULL, locale); decision.writeWorkflowAuditEntry(ctx, getWorkerURI(), "Day of week is " + day, false); return day; } catch (Exception e) { decision.setContextLiteral(ctx, getWorkerURI(), getStepName(), "Exception in workflow : " + e.getLocalizedMessage()); decision.setContextLiteral(ctx, getWorkerURI(), getErrName(), ExceptionToString.summary(e)); decision.writeWorkflowAuditEntry(ctx, getWorkerURI(), "Problem in " + getStepName() + ": " + ExceptionToString.getRootCause(e).getLocalizedMessage(), true); return getErrorTransition(); } }