List of usage examples for java.util TimeZone getDefault
public static TimeZone getDefault()
From source file:info.magnolia.cms.taglibs.util.BaseImageTag.java
/** * Create a new imageNode with the image in it. The node is saved under a node that groups all image nodes, whose * name is set to the value of the attribute imageContentNodeName. The name of the node will be set to a name that * is unique for the image. The property that stores the image will be set to the value of * PROPERTIES_FILENAME_VALUE. A sub-node is also created that stores the image properties. * @param subString The text./*w w w .jav a 2 s .co m*/ * @param textImageNode The node that will contain the text images. */ protected void createImageNode(File imageFile, Content imageNode) throws PathNotFoundException, AccessDeniedException, RepositoryException, FileNotFoundException, IOException { // Create and save the image data NodeData data; data = imageNode.getNodeData(getFilename()); if (!data.isExist()) { data = imageNode.createNodeData(getFilename(), PropertyType.BINARY); } InputStream iis = new FileInputStream(imageFile); data.setValue(iis); IOUtils.closeQuietly(iis); data.setAttribute(FileProperties.PROPERTY_FILENAME, getFilename()); data.setAttribute(FileProperties.PROPERTY_CONTENTTYPE, PROPERTIES_CONTENTTYPE_VALUE); Calendar value = new GregorianCalendar(TimeZone.getDefault()); data.setAttribute(FileProperties.PROPERTY_LASTMODIFIES, value); data.setAttribute(FileProperties.PROPERTY_SIZE, Long.toString(imageFile.length())); data.setAttribute(FileProperties.PROPERTY_EXTENSION, PROPERTIES_EXTENSION_VALUE); InputStream raf = null; try { ImageInfo ii = new ImageInfo(); raf = new FileInputStream(imageFile); ii.setInput(raf); if (ii.check()) { data.setAttribute(FileProperties.PROPERTY_WIDTH, Long.toString(ii.getWidth())); data.setAttribute(FileProperties.PROPERTY_HEIGHT, Long.toString(ii.getHeight())); } } catch (FileNotFoundException e) { log.error("FileNotFoundException caught when parsing {}, image data will not be available", imageFile.getAbsolutePath()); } finally { IOUtils.closeQuietly(raf); } // delete the temporary file imageFile.delete(); // save the new image node imageNode.save(); }
From source file:com.snowplowanalytics.snowplow.collectors.clojure.SnowplowAccessLogValve.java
/** * Set the date format date based log rotation. *//*from w ww .j a v a 2 s. co m*/ public void setFileDateFormat(String fileDateFormat) { String newFormat; if (fileDateFormat == null) { newFormat = ""; } else { newFormat = fileDateFormat; } this.fileDateFormat = newFormat; synchronized (this) { fileDateFormatter = new SimpleDateFormat(newFormat, Locale.US); fileDateFormatter.setTimeZone(TimeZone.getDefault()); } }
From source file:com.funambol.json.gui.GuiServlet.java
private String doEmptyGroup(HttpServletRequest request) throws Exception { String group = getRequestData(request, GROUP, true); Repository rep = new Repository((String) request.getSession().getAttribute("username"), TimeZone.getDefault(), "UTF-8"); rep.deleteAllItems(group);//from ww w . j a v a2 s . c o m return operationExecuted(EMPTYALL, request); }
From source file:com.serotonin.m2m2.Common.java
public static DateTimeZone getUserDateTimeZone(User user) { if (user != null) return user.getDateTimeZoneInstance(); return DateTimeZone.forID(TimeZone.getDefault().getID()); }
From source file:com.rogchen.common.xml.UtilDateTime.java
/** * ? /* ww w .j a va 2s . com*/ * * @param stamp * @param daysLater * @param monthsLater * @param yearsLater * @return */ public static Timestamp getYearStart(Timestamp stamp, int daysLater, int monthsLater, int yearsLater) { return getYearStart(stamp, daysLater, monthsLater, yearsLater, TimeZone.getDefault(), Locale.getDefault()); }
From source file:com.rapidminer.tools.Tools.java
public static TimeZone getTimeZone(int index) { if (index == SYSTEM_TIME_ZONE) { return TimeZone.getDefault(); } else {/*from w w w .jav a 2s . c o m*/ return TimeZone.getTimeZone(availableTimeZoneNames[index]); } }
From source file:org.jfree.data.time.junit.MillisecondTest.java
/** * Some checks for the getLastMillisecond() method. *//*from w w w. j a v a2 s . c om*/ public void testGetLastMillisecond() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.UK); TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); Millisecond m = new Millisecond(750, 1, 1, 1, 1, 1, 1970); assertEquals(61750L, m.getLastMillisecond()); Locale.setDefault(saved); TimeZone.setDefault(savedZone); }
From source file:cn.com.sinosoft.util.time.DurationFormatUtils.java
/** * <p>Formats the time gap as a string, using the specified format. * Padding the left hand side of numbers with zeroes is optional. * //from w ww. j a v a2 s .c om * @param startMillis the start of the duration * @param endMillis the end of the duration * @param format the way in which to format the duration * @return the time as a String */ public static String formatPeriod(long startMillis, long endMillis, String format) { return formatPeriod(startMillis, endMillis, format, true, TimeZone.getDefault()); }
From source file:org.jfree.data.time.MonthTest.java
/** * Some checks for the getLastMillisecond() method. *///from w w w . j ava2s .com @Test public void testGetLastMillisecond() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.UK); TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); Month m = new Month(3, 1970); assertEquals(7772399999L, m.getLastMillisecond()); Locale.setDefault(saved); TimeZone.setDefault(savedZone); }
From source file:org.jfree.data.time.DayTest.java
/** * Some checks for the getLastMillisecond() method. */// w ww. ja v a 2 s. com @Test public void testGetLastMillisecond() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.UK); TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); Day d = new Day(1, 1, 1970); assertEquals(82799999L, d.getLastMillisecond()); Locale.setDefault(saved); TimeZone.setDefault(savedZone); }