java.text.SimpleDateFormat Java Examples

The following examples show how to use java.text.SimpleDateFormat. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultAccessLogReceiver.java    From quarkus-http with Apache License 2.0 5 votes vote down vote up
private void calculateChangeOverPoint() {
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.SECOND, 0);
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.HOUR_OF_DAY, 0);
    calendar.add(Calendar.DATE, 1);
    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd", Locale.US);
    currentDateString = df.format(new Date());
    // if there is an existing default log file, use the date last modified instead of the current date
    if (Files.exists(defaultLogFile)) {
        try {
            currentDateString = df.format(new Date(Files.getLastModifiedTime(defaultLogFile).toMillis()));
        } catch(IOException e){
            // ignore. use the current date if exception happens.
        }
    }
    changeOverPoint = calendar.getTimeInMillis();
}
 
Example #2
Source File: MessagesFragment.java    From tindroid with Apache License 2.0 5 votes vote down vote up
private File createImageFile(Activity activity) throws IOException {
    // Create an image file name
    String imageFileName = "IMG_" +
            new SimpleDateFormat("yyMMdd_HHmmss", Locale.getDefault()).format(new Date()) + "_";
    File storageDir = activity.getExternalFilesDir(Environment.DIRECTORY_PICTURES);
    File imageFile = File.createTempFile(
            imageFileName,  // prefix
            ".jpg",  // suffix
            storageDir      // directory
    );

    // Make sure directories exist.
    File path = imageFile.getParentFile();
    if (path != null) {
        path.mkdirs();
    }

    return imageFile;
}
 
Example #3
Source File: SmsEchartsServiceImpl.java    From HIS with Apache License 2.0 5 votes vote down vote up
@Override
public SmsPatientsStatisticsResult totalPatients() {
    SmsPatientsStatisticsResult smsPatientsStatisticsResult = new SmsPatientsStatisticsResult();
    List<String> dateOfSevenDays = new ArrayList<>(7);
    List<Long> numOfPatients = new ArrayList<>(7);
    Date today = DateUtil.setMilliSecond(DateUtil.getDate(new Date()),0);
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
    for (int i=0;i<7;i++){
        dateOfSevenDays.add(formatter.format(DateUtil.getDateBefore(today,7-i)));
    }
    SmsWorkloadRecordExample smsWorkloadRecordExample = new SmsWorkloadRecordExample();
    for (int i=7;i>0;i--){
        smsWorkloadRecordExample.clear();
        smsWorkloadRecordExample.createCriteria().andDateEqualTo(DateUtil.getDateBefore(today,i)).andTypeEqualTo(2);
        //smsWorkloadRecordExample.setOrderByClause("date desc");
        List<SmsWorkloadRecord> smsWorkloadRecordList = smsWorkloadRecordMapper.selectByExample(smsWorkloadRecordExample);
        if (!smsWorkloadRecordList.isEmpty()){
            Long num = 0l;
            for (SmsWorkloadRecord smsWorkloadRecord : smsWorkloadRecordList){
                num = num + smsWorkloadRecord.getRegistrationNum();
            }
            numOfPatients.add(num);
        }

    }
    smsPatientsStatisticsResult.setDateOfSevenDays(dateOfSevenDays);
    smsPatientsStatisticsResult.setNumOfPatients(numOfPatients);
    return smsPatientsStatisticsResult;
}
 
Example #4
Source File: MainActivity.java    From arcgis-runtime-samples-android with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);

  // create a simple date formatter to parse strings to date
  mSimpleDateFormatter = new SimpleDateFormat(getString(R.string.date_format), Locale.US);

  // inflate MapView from layout
  mMapView = findViewById(R.id.mapView);

  // create a map with the BasemapType topographic
  ArcGISMap map = new ArcGISMap(Basemap.createTopographic());

  //center for initial viewpoint
  Point center = new Point(-13671170, 5693633, SpatialReference.create(3857));

  //set initial viewpoint
  map.setInitialViewpoint(new Viewpoint(center, 57779));

  // set the map to the map view
  mMapView.setMap(map);

  // initialize geoprocessing task with the url of the service
  mGeoprocessingTask = new GeoprocessingTask(getString(R.string.hotspot_911_calls));
  mGeoprocessingTask.loadAsync();

  FloatingActionButton calendarFAB = findViewById(R.id.calendarButton);

  calendarFAB.setOnClickListener(new View.OnClickListener() {
    @Override public void onClick(View v) {
      showDateRangeDialog();
    }
  });

  calendarFAB.performClick();
}
 
Example #5
Source File: ExecutionHelper.java    From ice with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * This operation creates a standard header that contains information about
 * the job being launched. It is used primarily by the run() operation.
 *
 * @param logName
 *            The name that should be used to identify the log in its
 *            header.
 * @return The header.
 */
public String createOutputHeader(String logName, String fullCMD) {

	// Local Declarations
	String header = null, localHostname = null;

	// Get the identity of this machine as the point of origin for the job
	// launch
	try {
		// Get the address of localhost
		InetAddress addr = InetAddress.getLocalHost();
		// Get the hostname
		localHostname = addr.getHostName();
	} catch (UnknownHostException e) {
		logger.error(getClass().getName() + " Exception!", e);
	}

	// Add the date and time
	header = "# Job launch date: ";
	header += new SimpleDateFormat("yyyyMMdd_HHmmss").format(Calendar.getInstance().getTime()) + "\n";
	// Add the point of origin
	header += "# Launch host: " + localHostname + "\n";
	// Add the target machine
	header += "# Target host: localhost \n";
	// Add the execution command
	header += "# Command Executed: " + fullCMD.replace("\n", ";") + "\n";
	// Add the working directory
	header += "# Working directory: " + execDictionary.get("localJobLaunchDirectory") + "\n";
	// Add an empty line
	header += "\n";

	return header;
}
 
Example #6
Source File: AnalyticsUDF.java    From product-ei with Apache License 2.0 5 votes vote down vote up
/**
 * Get month from date string
 * @param date in the format of eg:Thu Sep 24 09:35:56 IST 2015
 * @return long value of the initial date of the month
    */
private static long getMonthFromDate (String date) {
	String[] dateArray = date.split(AnalyticsUDFConstants.SPACE_SEPARATOR);
	try {
		Date d = new SimpleDateFormat(AnalyticsUDFConstants.DATE_FORMAT_MONTH).parse(dateArray[1] +
				AnalyticsUDFConstants.SPACE_SEPARATOR + dateArray[dateArray.length-1]);
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(d);
		return calendar.getTimeInMillis();
	} catch (ParseException e) {
		return -1;
	}
}
 
Example #7
Source File: BoxDeveloperEditionAPIConnection.java    From box-java-sdk with Apache License 2.0 5 votes vote down vote up
private NumericDate getDateForJWTConstruction(BoxAPIException apiException, long secondsSinceResponseDateReceived) {
    NumericDate currentTime;
    List<String> responseDates = apiException.getHeaders().get("Date");

    if (responseDates != null) {
        String responseDate = responseDates.get(0);
        SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss zzz");
        try {
            Date date = dateFormat.parse(responseDate);
            currentTime = NumericDate.fromMilliseconds(date.getTime());
            currentTime.addSeconds(secondsSinceResponseDateReceived);
        } catch (ParseException e) {
            currentTime = NumericDate.now();
        }
    } else {
        currentTime = NumericDate.now();
    }
    return currentTime;
}
 
Example #8
Source File: DateUtil.java    From sofa-acts with Apache License 2.0 5 votes vote down vote up
public static Date parseDateNoTime(String sDate) throws ParseException {
    DateFormat dateFormat = new SimpleDateFormat(dtShort);

    if ((sDate == null) || (sDate.length() < dtShort.length())) {
        throw new ParseException("length too little", 0);
    }

    if (!StringUtils.isNumeric(sDate)) {
        throw new ParseException("not all digit", 0);
    }

    return dateFormat.parse(sDate);
}
 
Example #9
Source File: ODateUtils.java    From framework with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Returns date before given days
 *
 * @param days days to before
 * @return string date string before days
 */
public static String getDateBefore(int days) {
    Date today = new Date();
    Calendar cal = new GregorianCalendar();
    cal.setTime(today);
    cal.add(Calendar.DAY_OF_MONTH, days * -1);
    Date date = cal.getTime();
    SimpleDateFormat gmtFormat = new SimpleDateFormat();
    gmtFormat.applyPattern("yyyy-MM-dd 00:00:00");
    TimeZone gmtTime = TimeZone.getTimeZone("GMT");
    gmtFormat.setTimeZone(gmtTime);
    return gmtFormat.format(date);
}
 
Example #10
Source File: StatusCheckerTimer.java    From oxTrust with MIT License 5 votes vote down vote up
private void getFacterBandwidth(String facterResult, ConfigurationStatus configuration) {
	log.debug("Setting bandwidth attributes");
	if (facterResult != null) {
		String[] lines = facterResult.split("\n");
		SimpleDateFormat monthFormat = new SimpleDateFormat("MMM ''yy");
		String month = monthFormat.format(new Date());
		Pattern curent = Pattern.compile("^\\s*" + month);

		for (String line : lines) {
			Matcher match = curent.matcher(line);
			if (match.find()) {
				line = line.replaceAll("^\\s*" + month, "");
				String[] values = line.split("\\|");
				configuration.setGluuBandwidthRX(values[0].replaceAll("^\\s*", "").replaceAll("\\s*$", ""));
				configuration.setGluuBandwidthTX(values[1].replaceAll("^\\s*", "").replaceAll("\\s*$", ""));
			}
		}
	} else {
		configuration.setGluuBandwidthRX("-1");
		configuration.setGluuBandwidthTX("-1");
	}

}
 
Example #11
Source File: DateUtil.java    From das with Apache License 2.0 5 votes vote down vote up
final public static int str2Int(String fromat, String time) {
    SimpleDateFormat df = DateUtil.getSdf(fromat);//yyyy-MM-dd HH:mm:ss
    SimpleDateFormat sdf = DateUtil.getSdf(DATE_FORMAT_INT);
    Calendar cal = Calendar.getInstance();
    try {
        if (null != time && time.length() > 5) {
            Date date = df.parse(time);
            cal.setTime(date);
        }
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return Integer.valueOf(sdf.format(cal.getTime()));
}
 
Example #12
Source File: StringUtilsBasic.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 判断字符串是否为日期
 * @param str
 * 			要判断的字符串
 * @param format
 * 			日期格式,按该格式检查字符串
 * @return boolean
 * 			符合为true,不符合为false
 */
public static boolean isDate(String str, String format) {
	if (hasLength(str)) {
		SimpleDateFormat formatter = new SimpleDateFormat(format);
		formatter.setLenient(false);
		try {
			formatter.format(formatter.parse(str));
		} catch (Exception e) {
			return false;
		}
		return true;
	}
	return false;
}
 
Example #13
Source File: DateFormatter.java    From journaldev with MIT License 5 votes vote down vote up
/**
 * Utility function to convert java Date to TimeZone format
 * @param date
 * @param format
 * @param timeZone
 * @return
 */
public static String formatDateToString(Date date, String format,
		String timeZone) {
	// null check
	if (date == null) return null;
	// create SimpleDateFormat object with input format
	SimpleDateFormat sdf = new SimpleDateFormat(format);
	// default system timezone if passed null or empty
	if (timeZone == null || "".equalsIgnoreCase(timeZone.trim())) {
		timeZone = Calendar.getInstance().getTimeZone().getID();
	}
	// set timezone to SimpleDateFormat
	sdf.setTimeZone(TimeZone.getTimeZone(timeZone));
	// return Date in required format with timezone as String
	return sdf.format(date);
}
 
Example #14
Source File: MiniMRCluster.java    From hadoop-gpu with Apache License 2.0 5 votes vote down vote up
/**
 * Create the job tracker and run it.
 */
public void run() {
  try {
    jc = (jc == null) ? createJobConf() : createJobConf(jc);
    File f = new File("build/test/mapred/local").getAbsoluteFile();
    jc.set("mapred.local.dir",f.getAbsolutePath());
    jc.setClass("topology.node.switch.mapping.impl", 
        StaticMapping.class, DNSToSwitchMapping.class);
    String id = 
      new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date());
    tracker = JobTracker.startTracker(jc, id);
    tracker.offerService();
  } catch (Throwable e) {
    LOG.error("Job tracker crashed", e);
    isActive = false;
  }
}
 
Example #15
Source File: DateFormat.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private static String getDateFormatString(Context context) {
    final Locale locale = context.getResources().getConfiguration().locale;
    java.text.DateFormat df = java.text.DateFormat.getDateInstance(
            java.text.DateFormat.SHORT, locale);
    if (df instanceof SimpleDateFormat) {
        return ((SimpleDateFormat) df).toPattern();
    }

    throw new AssertionError("!(df instanceof SimpleDateFormat)");
}
 
Example #16
Source File: Fragment_day.java    From privacy-friendly-netmonitor with GNU General Public License v3.0 5 votes vote down vote up
private int getEntityHour(ReportEntity reportEntity) {
    String string_timestamp = reportEntity.getTimeStamp();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
    Date entity_date = null;
    try {
        entity_date = sdf.parse(string_timestamp);
    } catch (ParseException e) {
        e.printStackTrace();
    }

    return entity_date.getHours();
}
 
Example #17
Source File: DataGenerator.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
protected String generateDate(Date baseDate) {

    final SimpleDateFormat formatterTimestamp = new SimpleDateFormat(
        getFormatterTimestamp());
    try {
      baseDate = formatterTimestamp.parse(getBaseTime());
    } catch (ParseException e) {
      e.printStackTrace();
      System.exit(2);
    }

    double addOn = Math.random() * 86400000 * 100;

    long newTime = baseDate.getTime() + (long)addOn;
    Date newDate = new Date(newTime);

    return formatterTimestamp.format(newDate);
  }
 
Example #18
Source File: MissingSchemaReference.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
	SimpleDateFormat df = new SimpleDateFormat("[HH:mm:ss] "); 

	System.out.println(df.format(new Date()) + "setting up citygml4j context and CityGML builder");
	CityGMLContext ctx = CityGMLContext.getInstance();
	CityGMLBuilder builder = ctx.createCityGMLBuilder();

	System.out.println(df.format(new Date()) + "setting up schema handler");
	SchemaHandler schemaHandler = SchemaHandler.newInstance();
	schemaHandler.setSchemaEntityResolver(new SchemaEntityResolver());
	schemaHandler.setErrorHandler(new SchemaParseErrorHandler());

	System.out.println(df.format(new Date()) + "reading ADE-enriched CityGML file LOD0_Railway_NoiseADE_missing_ADE_reference_v200.gml");
	System.out.println(df.format(new Date()) + "note: the input document is lacking a reference to the ADE schema document");
	CityGMLInputFactory in = builder.createCityGMLInputFactory(schemaHandler);
	in.setProperty(CityGMLInputFactory.FEATURE_READ_MODE, FeatureReadMode.SPLIT_PER_FEATURE);
	
	CityGMLReader reader = in.createCityGMLReader(new File("datasets/LOD0_Railway_NoiseADE_missing_ADE_reference_v200.gml"));
	
	while (reader.hasNext()) {
		CityGML citygml = reader.nextFeature();
		
		if (citygml instanceof AbstractFeature)
			System.out.println("Found CityGML: " + citygml.getCityGMLClass());
		else if (citygml instanceof ADEGenericElement)
			System.out.println("Found ADE: " + ((ADEGenericElement)citygml).getContent().getLocalName());
	}
	
	reader.close();
	System.out.println(df.format(new Date()) + "sample citygml4j application successfully finished");
}
 
Example #19
Source File: CoursesController.java    From training with MIT License 5 votes vote down vote up
private Course mapToEntity(CourseDto dto) throws ParseException {
	Course newEntity = new Course();
	newEntity.setName(dto.name);
	newEntity.setStartDate(new SimpleDateFormat("dd-MM-yyyy").parse(dto.startDate));
	newEntity.setDescription(dto.description); // SOLUTION
	newEntity.setTeacher(teacherRepo.getById(dto.teacherId));
	return newEntity;
}
 
Example #20
Source File: SystemStatus.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
private void setSensorStatus(){
    StringBuilder sensor_status= new StringBuilder();
    if(Sensor.isActive()){
        Sensor sens = Sensor.currentSensor();
        Date date = new Date(sens.started_at);
        DateFormat df = new SimpleDateFormat();
        sensor_status.append(df.format(date));
        sensor_status.append(" (");
        sensor_status.append((System.currentTimeMillis() - sens.started_at) / (1000 * 60 * 60 * 24));
        sensor_status.append("d ");
        sensor_status.append(((System.currentTimeMillis() - sens.started_at) % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
        sensor_status.append("h)");
    } else {
        sensor_status.append("not available");
    }
    sensor_status_view.setText(sensor_status.toString());

}
 
Example #21
Source File: RemoteDirListTask.java    From satstat with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected RemoteFile[] doInBackground(String... params) {
	Uri uri = Uri.parse(params[0]);
	RemoteFile[] rfiles = null;
	SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.ROOT);
	df.setTimeZone(TimeZone.getDefault());
	if (uri.getScheme() == null)
		return null;
	if (uri.getScheme().equals("http") || uri.getScheme().equals("https"))
		rfiles = HttpDownloader.list(params[0]);
	
	if (rfiles == null)
		Log.w(TAG, "Error – could not retrieve content!");
	else if (rfiles.length == 0)
		Log.w(TAG, "Remote directory is empty.");
	/*
	else {
		Log.d(TAG, "Remote directory contents:");
		for (RemoteFile rf : rfiles)
			Log.d(TAG, String.format("\n\t%s \t%s \t%s \t%s",
				rf.isDirectory ? "D" : "F",
				df.format(new Date(rf.timestamp)),
				rf.getFriendlySize(),
				rf.name));
	}
	 */
	return rfiles;
}
 
Example #22
Source File: JobUtils.java    From seldon-server with Apache License 2.0 5 votes vote down vote up
public static long dateToUnixDays(String dateString) throws ParseException {
    DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
    dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
    Date date = dateFormat.parse(dateString);

    return ((date.getTime() / 1000) / 86400);
}
 
Example #23
Source File: NettyServer.java    From netty_push_server with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static void main(String[] args) {
	String dateString = new Date().toString();

	System.out.println(dateString);
	SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss Z yyyy", Locale.US);// MMM
	// dd
	// hh:mm:ss
	// Z
	// yyyy
	// DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.FULL,
	// Locale.getDefault());
	try {
		System.out.println(sdf.parse(dateString));
	} catch (ParseException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
Example #24
Source File: 1_FastDateFormat.java    From SimFix with GNU General Public License v2.0 5 votes vote down vote up
/**
 * <p>Gets a date formatter instance using the specified style, time
 * zone and locale.</p>
 * 
 * @param style  date style: FULL, LONG, MEDIUM, or SHORT
 * @param timeZone  optional time zone, overrides time zone of
 *  formatted date
 * @param locale  optional locale, overrides system locale
 * @return a localized standard date formatter
 * @throws IllegalArgumentException if the Locale has no date
 *  pattern defined
 */
public static synchronized FastDateFormat getDateInstance(int style, TimeZone timeZone, Locale locale) {
    Object key = new Integer(style);
    if (timeZone != null) {
        key = new Pair(key, timeZone);
    }

    if (locale != null) {
        key = new Pair(key, locale);
    }


    FastDateFormat format = (FastDateFormat) cDateInstanceCache.get(key);
    if (format == null) {
        if (locale == null) {
            locale = Locale.getDefault();
        }
        try {
            SimpleDateFormat formatter = (SimpleDateFormat) DateFormat.getDateInstance(style, locale);
            String pattern = formatter.toPattern();
            format = getInstance(pattern, timeZone, locale);
            cDateInstanceCache.put(key, format);
            
        } catch (ClassCastException ex) {
            throw new IllegalArgumentException("No date pattern for locale: " + locale);
        }
    }
    return format;
}
 
Example #25
Source File: CommonUtils.java    From pacbot with Apache License 2.0 5 votes vote down vote up
/**
 * Date format.
 *
 * @param dateInString the date in string
 * @param formatFrom the format from
 * @param formatTo the format to
 * @return the date
 * @throws ParseException the parse exception
 */
public static Date dateFormat(final String dateInString, String formatFrom, String formatTo)
        throws java.text.ParseException {
    String dateDormatter = "MM/dd/yyyy";
    if (StringUtils.isNullOrEmpty(formatFrom)) {
        formatFrom = dateDormatter;
    }
    if (StringUtils.isNullOrEmpty(formatTo)) {
        formatTo = dateDormatter;
    }
    DateFormat dateFromFormater = new SimpleDateFormat(formatFrom);
    DateFormat dateToFormater = new SimpleDateFormat(formatTo);
    return dateToFormater.parse(dateToFormater.format(dateFromFormater.parse(dateInString)));
}
 
Example #26
Source File: FloatConversionUtil.java    From enkan with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * {@link Float}に変換します。
 *
 * @param o
 *            変換元のオブジェクト
 * @param pattern
 *            パターン文字列
 * @return 変換された{@link Float}
 */
public static Float toFloat(final Object o, final String pattern) {
    if (o == null) {
        return null;
    } else if (o instanceof Float) {
        return (Float) o;
    } else if (o instanceof Number) {
        return ((Number) o).floatValue();
    } else if (o instanceof String) {
        return toFloat((String) o);
    } else if (o instanceof java.util.Date) {
        if (pattern != null) {
            return Float.parseFloat(new SimpleDateFormat(pattern).format(o));
        }
        return (float) ((java.util.Date) o).getTime();
    } else {
        return toFloat(o.toString());
    }
}
 
Example #27
Source File: PetitionManager.java    From L2jBrasil with GNU General Public License v3.0 5 votes vote down vote up
public void viewPetition(L2PcInstance activeChar, int petitionId)
{
	if (!activeChar.isGM())
		return;

	if (!isValidPetition(petitionId))
		return;

	Petition currPetition = getPendingPetitions().get(petitionId);
       StringBuilder htmlContent = new StringBuilder("<html><body>");
	SimpleDateFormat dateFormat = new SimpleDateFormat("EEE dd MMM HH:mm z");

	htmlContent.append("<center><br><font color=\"LEVEL\">Petition #" + currPetition.getId() + "</font><br1>");
	htmlContent.append("<img src=\"L2UI.SquareGray\" width=\"200\" height=\"1\"></center><br>");
	htmlContent.append("Submit Time: " + dateFormat.format(new Date(currPetition.getSubmitTime())) + "<br1>");
	htmlContent.append("Petitioner: " + currPetition.getPetitioner().getName() + "<br1>");
	htmlContent.append("Petition Type: " + currPetition.getTypeAsString() + "<br>" + currPetition.getContent() + "<br>");
	htmlContent.append("<center><button value=\"Accept\" action=\"bypass -h admin_accept_petition " + currPetition.getId() + "\"" +
	"width=\"50\" height=\"15\" back=\"sek.cbui94\" fore=\"sek.cbui92\"><br1>");
	htmlContent.append("<button value=\"Reject\" action=\"bypass -h admin_reject_petition " + currPetition.getId() + "\" " +
	"width=\"50\" height=\"15\" back=\"sek.cbui94\" fore=\"sek.cbui92\"><br>");
	htmlContent.append("<button value=\"Back\" action=\"bypass -h admin_view_petitions\" width=\"40\" height=\"15\" back=\"sek.cbui94\" " +
	"fore=\"sek.cbui92\"></center>");
	htmlContent.append("</body></html>");

	NpcHtmlMessage htmlMsg = new NpcHtmlMessage(0);
	htmlMsg.setHtml(htmlContent.toString());
	activeChar.sendPacket(htmlMsg);
}
 
Example #28
Source File: FileItem.java    From rcloneExplorer with MIT License 5 votes vote down vote up
private long modTimeZonedToMillis(String modTime) {
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
    int index = modTime.lastIndexOf("+");
    if (index == -1) {
        index = modTime.lastIndexOf("-");
    }
    int fractionIndex = modTime.indexOf('.');
    String reducedString = fractionIndex == -1 ? modTime : modTime.substring(0, fractionIndex) + modTime.substring(index);
    try {
        return format.parse(reducedString).getTime();
    } catch (ParseException e) {
        return 0L;
    }
}
 
Example #29
Source File: BarMegerTest.java    From crypto-bot with Apache License 2.0 5 votes vote down vote up
/**
 * Test three tick merge with other timestamps
 * @throws InterruptedException
 * @throws IOException
 * @throws ParseException
 */
@Test(timeout=6000)
public void testTickMerger4() throws InterruptedException, IOException, ParseException {
	
       final SimpleDateFormat parser = new SimpleDateFormat("HH:mm:ss");
       
	final CountDownLatch latch = new CountDownLatch(2);
	
	final BiConsumer<BitfinexCurrencyPair, Bar> tickConsumer = (s, t) -> {
		latch.countDown();
	};
	
	final BarMerger tickMerger = new BarMerger(BitfinexCurrencyPair.BTC_USD, Timeframe.MINUTES_1, tickConsumer);
	tickMerger.addNewPrice(parser.parse("01:01:23").getTime(), new BigDecimal(1.0), new BigDecimal(5.0));
	tickMerger.addNewPrice(parser.parse("01:01:33").getTime(), new BigDecimal(2.0), new BigDecimal(5.0));
	tickMerger.addNewPrice(parser.parse("02:02:53").getTime(), new BigDecimal(2.0), new BigDecimal(5.0));

	tickMerger.close();
	
	latch.await();
}
 
Example #30
Source File: ElementMetaDataTable.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void applyLocaleSettings( final LocaleSettings localeSettings ) {
  final SimpleDateFormat isoDateFormat = createSafely( localeSettings.getDatetimeFormatPattern(),
    WorkspaceSettings.DATETIME_FORMAT_DEFAULT, localeSettings.getLocale() );
  final TimeZone timeZone = localeSettings.getTimeZone();
  isoDateFormat.setTimeZone( timeZone );
  setDefaultRenderer( Date.class, new FormattingTableCellRenderer( isoDateFormat ) );
  setDefaultRenderer( Timestamp.class, new FormattingTableCellRenderer( isoDateFormat ) );

  final DateCellEditor dateCellEditor = new DateCellEditor( Date.class );
  dateCellEditor.setDateFormat( isoDateFormat );
  setDefaultEditor( Date.class, dateCellEditor );

  final DateCellEditor timestampEditor = new DateCellEditor( Timestamp.class );
  timestampEditor.setDateFormat( isoDateFormat );
  setDefaultEditor( Timestamp.class, timestampEditor );

  final SimpleDateFormat dateFormat = createSafely( localeSettings.getDateFormatPattern(),
    WorkspaceSettings.DATE_FORMAT_DEFAULT, localeSettings.getLocale() );
  dateFormat.setTimeZone( timeZone );
  setDefaultRenderer( java.sql.Date.class, new FormattingTableCellRenderer( dateFormat ) );

  final DateCellEditor sqlDateCellEditor = new DateCellEditor( java.sql.Date.class );
  sqlDateCellEditor.setDateFormat( dateFormat );
  setDefaultEditor( java.sql.Date.class, sqlDateCellEditor );

  final SimpleDateFormat timeFormat = createSafely( localeSettings.getTimeFormatPattern(),
    WorkspaceSettings.TIME_FORMAT_DEFAULT, localeSettings.getLocale() );
  timeFormat.setTimeZone( timeZone );
  setDefaultRenderer( Time.class, new FormattingTableCellRenderer( timeFormat ) );

  final TimeCellEditor timeCellEditor = new TimeCellEditor( Time.class );
  timeCellEditor.setDateFormat( timeFormat );
  setDefaultEditor( Time.class, timeCellEditor );
}