/** * Standard constructor for WOComponent subclasses. * * @param context context of a transaction * @see WOComponent#pageWithName(String) * @see WOApplication#pageWithName(String, WOContext) */ public ERPublishCalendarPage(WOContext context) { super(context); events = new NSMutableArray(); calendarTimeZone = new NSTimestampFormatter ("%Z").format (new NSTimestamp()); dateTimeFormatter = new NSTimestampFormatter ("%Y%m%dT%H%M%S"); dateTimeFormatter.setDefaultFormatTimeZone (NSTimeZone.localTimeZone()); dateFormatter = new NSTimestampFormatter ("%Y%m%d"); dateFormatter.setDefaultFormatTimeZone (NSTimeZone.localTimeZone()); utcDateTimeFormatter = new NSTimestampFormatter ("%Y%m%dT%H%M%SZ"); utcDateTimeFormatter.setDefaultFormatTimeZone (NSTimeZone.timeZoneWithName ("UTC", false)); timeZoneFormatter = new NSTimestampFormatter ("%Z"); timeZoneFormatter.setDefaultFormatTimeZone (NSTimeZone.localTimeZone()); }
private static void backupSiteConfig() { try { File sc = fileForSiteConfig(); if ( sc.exists() ) { NSTimestampFormatter formatter = new NSTimestampFormatter("%Y%m%d%H%M%S%F"); File renamedFile = new File(pathForSiteConfig() + "." + formatter.format(new NSTimestamp())); sc.renameTo(renamedFile); } } catch (NSForwardException ne) { log.error("Cannot backup file {}. Possible Permissions Problem.", pathForSiteConfig()); } }
static public Format formatterForFormat(String calFormat) { synchronized(_calFormatDict) { if(calFormat == null) calFormat = _defaultCalendarFormatString; NSTimestampFormatter v = (NSTimestampFormatter)_calFormatDict.objectForKey(calFormat); if(v == null) { v = new NSTimestampFormatter(calFormat); setFormatterForFormat(v, calFormat); } return v; } } static public void setFormatterForFormat(Format formatter, String calFormat) {
if (className.equals("com.webobjects.foundation.NSTimestamp")) { String dateFormatterString = formatterForKey(selectedKey()); NSTimestampFormatter dateFormatter = new NSTimestampFormatter(dateFormatterString); Object objectValue = null; try { objectValue = dateFormatter.parseObject((value != null) ? value.toString() : ""); } catch (ParseException e) { if (NSLog.debugLoggingAllowedForLevelAndGroups(NSLog.DebugLevelDetailed, NSLog.DebugGroupWebObjects)) {
formatter = new NSTimestampFormatter(format); format = ((NSTimestampFormatter)formatter).pattern(); formatter = new NSTimestampFormatter(format);
public void setNextScheduledShutdown(NSTimestamp newtime) { _nextScheduledShutdown = newtime; _nextScheduledShutdownString = shutdownFormatter.format(_nextScheduledShutdown); }
/** ******** Constructors ********* */ // This constructor is for adding new instances through the UI public MInstance(MHost aHost, MApplication anApplication, Integer anID, MSiteConfig aConfig) { shutdownFormatter.setDefaultFormatTimeZone(NSTimeZone.timeZoneWithName("UTC", true)); values = new NSMutableDictionary(); _host = aHost; _application = anApplication; _siteConfig = aConfig; setApplicationName(_application.name()); setHostName(_host.name()); setId(anID); takeValuesFromApplication(); setSchedulingEnabled(Boolean.FALSE); setSchedulingType("DAILY"); setSchedulingHourlyStartTime(Integer.valueOf(3)); setSchedulingDailyStartTime(Integer.valueOf(3)); setSchedulingWeeklyStartTime(Integer.valueOf(3)); setSchedulingStartDay(Integer.valueOf(1)); // Sunday setSchedulingInterval(Integer.valueOf(12)); setGracefulScheduling(Boolean.TRUE); }
aDate = (NSTimestamp)StatsUtilities.dateFormatter.parseObject(aStartDate); aRunningTime = (aDate.getTime() - System.currentTimeMillis()) / 1000; } catch (java.text.ParseException ex) {
public String textFieldValue() { if (_textFieldValue != null) { return _textFieldValue; } Object value = value(); setValue(value); if (value == null) { return null; } else if (value instanceof String) { return (String) value; } else { java.text.Format formatter = null; String className = valueClassNameForKey(selectedKey()); if (className.equals("com.webobjects.foundation.NSTimestamp")) { String dateFormatterString = formatterForKey(selectedKey()); formatter = new NSTimestampFormatter(dateFormatterString); } else if (className.equals("java.lang.Number") || className.equals("java.math.BigDecimal")) { String numberFormatterString = formatterForKey(selectedKey()); formatter = new NSNumberFormatter(numberFormatterString); } return (formatter != null) ? formatter.format(value) : value.toString(); } }
public void addDeath() { _deaths.addObject(MInstance.dateFormatter.format(new NSTimestamp())); }
public MInstance(NSDictionary aDict, MSiteConfig aConfig) { shutdownFormatter.setDefaultFormatTimeZone(NSTimeZone.timeZoneWithName("UTC", true)); values = new NSMutableDictionary(aDict); _host = aConfig.hostWithName(hostName()); _application = aConfig.applicationWithName(applicationName()); _siteConfig = aConfig; calculateNextScheduledShutdown(); }
/** * This class corresponds to one property. indexModel --> properties --> a property * * @param index the index * @param name the property name (a key or keypath) * @param dict the property definition form indexModel */ IndexAttribute(ERIndex index, String name, NSDictionary dict) { _name = name; _termVector = (TermVector) classValue(dict, "termVector", TermVector.class, "YES"); _store = (Store) classValue(dict, "store", Store.class, "NO"); _index = (Index) classValue(dict, "index", Index.class, "ANALYZED"); String analyzerClass = (String) dict.objectForKey("analyzer"); if (analyzerClass == null) { analyzerClass = StandardAnalyzer.class.getName(); } _analyzer = (Analyzer) create(analyzerClass); if (_analyzer == null && name.matches("\\w+_(\\w+)")) { // String locale = name.substring(name.lastIndexOf('_') + 1); } _format = (Format) create((String) dict.objectForKey("format")); String numberFormat = (String) dict.objectForKey("numberformat"); if (numberFormat != null) { _format = new NSNumberFormatter(numberFormat); } String dateformat = (String) dict.objectForKey("dateformat"); if (dateformat != null) { _format = new NSTimestampFormatter(dateformat); } }
value = ERXTimestampFormatter.dateFormatterForPattern(dateFormat).format(value);