001/* 002 * GWTEventService 003 * Copyright (c) 2011 and beyond, strawbill UG (haftungsbeschr?nkt) 004 * 005 * This is free software; you can redistribute it and/or modify it 006 * under the terms of the GNU Lesser General Public License as 007 * published by the Free Software Foundation; either version 3 of 008 * the License, or (at your option) any later version. 009 * Other licensing for GWTEventService may also be possible on request. 010 * Please view the license.txt of the project for more information. 011 * 012 * This software is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * You should have received a copy of the GNU Lesser General Public 018 * License along with this software; if not, write to the Free 019 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 020 * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 021 */ 022package de.novanic.eventservice.util; 023 024/** 025 * Utility class to ensure the platform independency. 026 * 027 * @author sstrohschein 028 * <br>Date: 11.01.2009 029 * <br>Time: 15:27:04 030 */ 031public final class PlatformUtil 032{ 033 private static final String NEW_LINE_CHAR; 034 035 static { 036 NEW_LINE_CHAR = createNewLineChar(); 037 } 038 039 private PlatformUtil() {} 040 041 /** 042 * Returns the new line character for the corresponding platform. 043 * @return new line character 044 */ 045 public static String getNewLine() { 046 return NEW_LINE_CHAR; 047 } 048 049 /** 050 * Returns the current time in milliseconds. 051 * @return current time in milliseconds 052 */ 053 public static long getCurrentTime() { 054 return System.currentTimeMillis(); 055 } 056 057 /** 058 * Returns the new line character for the corresponding platform. 059 * @return new line character 060 */ 061 private static String createNewLineChar() { 062 String theNewLineChar = System.getProperty("line.separator"); 063 if(theNewLineChar == null) { 064 theNewLineChar = "\n"; 065 } 066 return theNewLineChar; 067 } 068}