convert

Java BeanUtilsBean : Convert Date to String

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to run BeanUtilsBean.getInstance().populate(...) but on the HTML form, there is a field that carries String representation of Date of Birth. The object bean has the field type of java.util.Date Read some search from Ggl that have to build custom converters but not quite understand how to do that. Anyone can help? My code: public static void main(String[] args) { Map<String, String[]> formData = new HashMap<String, String[]>(); formData.put("email", new String[]{"danny@gmail.com"}); formData.put("firstName", new String[]{"danny"})

Convert Single Line Comments To Block Comments

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I need to convert single line comments (//...) to block comments (/*...*/) . I have nearly accomplished this in the following code; however, I need the function to skip any single line comment is already in a block comment. Currently it matches any single line comment, even when the single line comment is in a block comment. ## Convert Single Line Comment to Block Comments function singleLineComments( &$output ) { $output = preg_replace_callback('#//(.*)#m', create_function( '$match', 'return "/* " . trim(mb_substr($match[1], 0)) . " */";' )

using xslt stylesheet to convert xhtml blank lines to an XSL-FO blank line

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm using an XSLT stylesheet (by Antennahouse) to convert XHTML to an XSL-FO file. I defined a blank line in my XHTML file as 2 consecutive HTML BR tags. Now there is no native support for a blank line in the XSL-FO format. I want to work around this limitation by adding a height to the fo:block that the stylesheet inserts for a BR tag. However I'm new to the XSLT language and I'm having some problems doing this. I can figure out how to insert this height for every BR tag I encounter, but I only want the blank line to be inserted when there

Convert HttpContent into byte[]

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am currently working on a c# web API. For a specific call I need to send 2 images using an ajax call to the API, so that the API can save them as varbinary(max) in the database. How do you extract an Image or byte[] from a HttpContent object? How do I do this twice? Once for each image. - var authToken = $("#AuthToken").val(); var formData = new FormData($('form')[0]); debugger; $.ajax({ url: "/api/obj/Create/", headers: { "Authorization-Token": authToken }, type: 'POST', xhr: function () { var myXhr = $.ajaxSettings.xhr(); return myXhr; }

Convert UTC time to local time using Nodatime

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have been provided a time in this format "ddMMyyHHmmss". I know the time is in UTC format. I would like to use the NodaTime library to convert this to my local timezone but I can't seem to figure it out. My local timezone target is to be New Zealand. Here's what I have tried: var pattern = LocalDateTimePattern.CreateWithInvariantCulture("ddMMyyHHmmss"); var parseResult = pattern.Parse(utcDateTime); if (!parseResult.Success) { throw new InvalidDataException("Invalid time specified " + date + time); } var timeZone = DateTimeZoneProviders.Bcl

How to convert Excel values into buckets?

匿名 (未验证) 提交于 2019-12-03 08:44:33
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a set of data in Excel and in one column is a estimate (number of weeks) I want an Excel formula to bucket it into Small Medium Large where if the value is 0 - 10 then put it Small. If the value is 10 - 20 put it in Medium, etc . . . if there any elegant way of doing it besides having nested if statements all put together? 回答1: May be not quite what you were looking for but how about using conditional formatting functionality of Excel EDIT: As an alternate you could create a vba function that acts as a formula that will do the

How to convert a string data to a JSON object in python?

匿名 (未验证) 提交于 2019-12-03 08:44:33
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Here is the sample string i am receiving from one of the web services, body=%7B%22type%22%3A%22change%22%2C%22url%22%3A%22http%3A%2F%2Fapi.pachube.com%2Fv2%2Ftriggers%2F4100%22%2C%22environment%22%3A%7B%22feed%22%3A%22http%3A%2F%2Fapi.pachube.com%2Fv2%2Ffeeds%2F36133%22%2C%22title%22%3A%22Current+Cost+Bridge%22%2C%22description%22%3Anull%2C%22id%22%3A36133%7D%2C%22threshold_value%22%3Anull%2C%22timestamp%22%3A%222012-01-05T09%3A27%3A01Z%22%2C%22triggering_datastream%22%3A%7B%22url%22%3A%22http%3A%2F%2Fapi.pachube.com%2Fv2%2Ffeeds%2F36133

How do I convert epoch time to normal time in Perl?

匿名 (未验证) 提交于 2019-12-03 08:44:33
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I am attempting to write a Perl script that parses a log where on each line the second value is the date. The script takes in three arguments: the input log file, the start time, and the end time. The start and end time are used to parse out a certain value on each line that that falls between those two times. But to properly run this I am converting the start and end time to epoch time. The problem I am having is that to convert the loops 'i' value back to normal time to compare against the log file. After running localtime($i) I

R - data frame - convert to sparse matrix

匿名 (未验证) 提交于 2019-12-03 08:44:33
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a data frame which is mostly zeros (sparse data frame?) something similar to name,factor_1,factor_2,factor_3 ABC,1,0,0 DEF,0,1,0 GHI,0,0,1 The actual data is about 90,000 rows with 10,000 features. Can I convert this to a sparse matrix? I am expecting to gain time and space efficiencies by utilizing a sparse matrix instead of a data frame. Any help would be appreciated Update #1: Here is some code to generate the data frame. Thanks Richard for providing this x <- structure(list(name = structure(1:3, .Label = c("ABC", "DEF", "GHI"),

How to convert a 16 bit to an 8 bit image in OpenCV?

匿名 (未验证) 提交于 2019-12-03 08:44:33
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have a 16bit grayscale image and I want to convert it to a 8bit grayscale image in OpenCV for python to use it with various functions (like findContours etc.). Is it possible to do it in python or I have to switch to C++? 回答1: You can use numpy conversion methods as an OpenCV mat is a numpy array. This works: img8 = ( img16 / 256 ). astype ( 'uint8' ) 回答2: You can do this in Python using NumPy by mapping the image trough a lookup table. import numpy as np def map_uint16_to_uint8 ( img , lower_bound = None , upper_bound = None ):