Menu
  • HOME
  • TAGS

How can we convert a string to a user defined object in java [closed]

java,casting,data-type-conversion

You want to transfer a String into a Treecreat? You should give Treecreat a constructor like this. public Treecreat(String yourString){ this.myString = yourString; } So the String is in Treecreat and you can work with it in your method, with call the method in this way: add(new Treecreat(data). ...

Conversion from integer to time in ax 2012

data-type-conversion,dynamics-ax-2012

The AX TimeOfDay type is number of seconds from midnight. You can use time2Str function or use div and mod operand to calculate hours and minutes. Example: info(time2Str(31501, TimeSeparator::Colon, TimeFormat::AMPM)); ...

CGFloat not converting to UInt32?

swift,type-conversion,data-type-conversion

The CGFloat(...) part is fine; the error-message isn't saying that you can't explicitly convert an integer to a CGFloat, but rather, that you can't implicitly convert from a CGFloat to an Int. More specifically, I think it's complaining because of the final assignment x = ...; the part on the...

Changing over from double data type to decimal

mysql,double,decimal,data-type-conversion

Yes, you do have a risk of losing data unless planned carefully, but as long as you ensure that your data is already consistent and you choose correct length for the field you should be fine. Consider the following: ALTER TABLE yourtable MODIFY COLUMN yourcolumn DECIMAL; This will convert yourcolumn...

convert string generated from Number.toString to number

javascript,string,data-type-conversion

By using parseInt. parseInt(Number(100).toString(16), 16); parseInt(Number(1000).toString(36), 36); ...

SQL Server Numeric data type turns into Short_Text in MS Access

sql-server,sql-server-2008,ms-access,data-type-conversion,sqldatatypes

The reason is that you selected a number for precision which is 38 that is larger than the maximum acceptable precision by MS Access 2013 which is 28 So, It failed to map it to Number data type in access, that's why it was converted to short_text However, I see...

Why Float return different value and how can i solve it, Java

java,android,data-type-conversion

To format a decimal use: http://docs.oracle.com/javase/tutorial/i18n/format/decimalFormat.html In this case the format you want is ###.## An example of using this would be float f = 123456.78f; DecimalFormat format = new DecimalFormat("###.##'); String formatted = format.format(f); Note that if you are using this for monetary calculations you should use BigDecimal instead....

Converting dataframe to dataframe in R? Unexpected results

r,data.frame,data-type-conversion

data.frame starts of with ..., which is often populated with "tag/value" pairs to be combined as columns. Thus, data.frame(x = x, y = y) would work as you expected. as.data.frame expects a single object that can be coerced into a data.frame using one of the as.data.frame.* methods. It also has...

to_date and to_char issue

oracle11g,data-type-conversion,to-date,to-char

To select rows inserted in the last minute: select * from my_table where inserted_date > sysdate-1/(24*60); (This assumes your table has a date column called inserted_date that holds the date and time of insertion.) SYSDATE always returns the current date and time, but what you see in a tool like...

Convert string built bit map (100101) to int value in SQL

mysql,types,data-type-conversion

Try this SELECT CONV( BINARY( '100101' ) , 2, 10 ) It will do the trick. I was inspired by Convert a binary to decimal using MySQL EDIT In fact you can make it even more simple by using just CONV SELECT CONV( '100101' , 2, 10 ) See http://dev.mysql.com/doc/refman/5.5/en/mathematical-functions.html#function_conv...

My code does not run for large values of n

c,variables,integer,data-type-conversion

Yes, you cannot declare a very big local array because its sits in the call stack. I'm sure your local variable int f[]; is a typo (that won't compile). You probably meant (after having set n) something like int f[n]; so you are using a VLA. The call stack has...

How to use java.time.ZonedDateTime to generate a primitive long value in UTC

java,performance,coding-style,utc,data-type-conversion

ZonedDateTime value = ZonedDateTime.now(ZoneOffset.UTC); System.out.println(value.get(ChronoField.NANO_OF_SECOND)); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS"); long time = Long.parseLong(formatter.format(value)) * 100; System.out.println(time); ...

Setting Minute and Second component of Timestamp field to 0

sql,database,timestamp,teradata,data-type-conversion

Instead of casting from/to a string two times it's probably more efficient to substract intervals: ts - (EXTRACT(MINUTE FROM ts) * INTERVAL '01' MINUTE) - (EXTRACT(SECOND FROM ts) * INTERVAL '01' SECOND) If this is to much code simply put it in a SQL UDF....

Convert factors to Numerics in R

r,numeric,data-type-conversion,factors

if train_new is a data.frame and you want to change the columns starting with "Q1...", try this: train_new[,grep(pattern="^Q1",colnames(train_new))] = lapply(train_new[,grep(pattern="^Q1",colnames(train_new))],as.integer) or if not every column you are converting is a factor (could be char or numeric): train_new[,grep(pattern="^Q1",colnames(train_new))] = lapply(train_new[,grep(pattern="^Q1",colnames(train_new))], function(x) { as.integer(as.factor(x)) } ) Applied on a general data.frame df:...

How to use 'new' insted of 'malloc' in code [closed]

c++,malloc,data-type-conversion

The equivalent of SP->xs = malloc(size * sizeof(double)); is SP->xs = new double[size]; This does not require any #includes. To free the allocated array, use delete[]: delete[] SP->xs; The square brackets are important: without them, the code will compile but will have undefined behaviour. Since you're writing in C++, consider...

Processing data before saving to database Django Tastypie

django,timestamp,tastypie,data-type-conversion

Use the hydrate method on your resource. class EntryResource(ModelResource): def hydrate(self, bundle): if field in bundle.data: date = bundle.data['pub_date'] bundle.data['pub_date'] = time.strptime(date, "%Y-%m-%d %H:%M:%S") return bundle ...

Numerical inconsistency in .NET

c#,data-type-conversion,slimdx,numerical-stability

If this were my application and I was that concerned about the possible loss of integrity, I would recreate the appropriate methods using the required data types. .Net is a general platform that attempts to solve a majority of problems, but it can't solve them all. Although it may be...

SQL Server nvarchar to money/decimal conversion

sql,sql-server,data-type-conversion,sqldatatypes

Divide by 100. Convert(money, field) / 100 Try These Formats if you want : MonyFormat...

CHAR to HEX conversion in ABAP --> runtime error

sap,data-type-conversion,abap

I've just tested CHAR_HEX_CONVERSION and I get what I think is the same dump: For the statement "WRITE src TO dest" only flat, character-type data objects are supported at the argument position "dest". In this case, the operand "dest" has the non-character-type or non-flat type "X". The current program is...

Java: Taking String input in console and parsing into Int

java,string,data-type-conversion

The problem here is you are putting a char value to a int array resulting the unexpected behaviour. a[k][i][j] = inpline[k][i].charAt(j); I'm not sure but I think this will put the ASCII value related to the referring char value to your int array. Which will give you that unexpected answer....

Loss of precision in java

java,data-type-conversion

In the case of int to byte, there's no real concern about a loss of precision, because both types have the same degree of granularity. You'll get an error if you try to convert a literal with a value outside the range of byte to byte. (The error message given...

Convert datatype Clob to Varchar2 Oracle

sql,oracle,data-type-conversion,clob,varchar2

You can drop CLOB column, add the varchar2 column, and then 'fix' the column order using online table redefinition; assuming you're on a version that supports that and you have permission to use the DBMS_REDEFINITION package. Very simple demo for a table with a primary key: create table in_msg_board(col1 number...

Java integer to hex and to int

java,integer,hex,data-type-conversion

Based on the example you provided, my guess is that convertByteToHex(byte) is converting to a single-digit hex string when the byte value is less than 0x10. 16900 is 0x4204 and 1060 is 0x424. You need to ensure that the conversion is zero-padded to two digits. A much simpler approach is...

Printing real data type from sql server

php,sql-server,data-type-conversion

you can try this $variable = round($row['column_name'],2); //display 2 decimal ...

Native Query returns list with java.lang.Object instead of custom object type in JPA application

java,mysql,jpa,data-type-conversion

Try to give the classname you expect as the second argument of your createNativeQuery call: studentsInCourse = em .createNativeQuery( "SELECT * FROM Student WHERE id IN (SELECT student_id FROM CourseResult WHERE course_id = ?)", Student.class) .setParameter(1, course.getId()).getResultList(); ...

create table with time datatype and insertion time data in table

sql,oracle,timestamp,data-type-conversion

The message for ORA-01861 is literal does not match format string. This error means we're casting a string to another data type but the string has the wrong format. Your insert statement features two casts of a string to a TIMESTAMP datatype using the ANSI SQL style timestamp() function. This...

Identifying Data Type From Binary File

javascript,file,binary,data-type-conversion,8bit

That is hexadecimal. Each one of those 4-digit chunks are the equivalent of 2 bytes or 16 bits. As far as what it's supposed to represent, that is completely dependent upon how you choose to interpret it. The data itself does not provide context. For example, you could choose to...

Double becomes 0 when multiplied with int

c,double,data-type-conversion

The signature of atoi() is int atoi(const char *nptr); It will return an int value, not a float or double. In your case, input 0.1 is returned as 0. If you want a float value, try atof(). Note: as a suggestion, it's better to check for NULL before using the...

exporting java runtimes to matlab

java,matlab,file,data-type-conversion

A solution as mentioned by Daniel Save your java results in a .txt file that looks like that: 1 2 3 4 5 6 7 8 9 use textscan to convert it into a matlab variable file= fopen('whatever.txt') Variable=textscan(file,'%d %d %d') Hoping this is useful to someone else. Any other...

Split string to convert to datetime causes an error

c#,datetime,data-type-conversion

Use MM instead of MMMM: string[] formats = { "yyyy/MM/dd" }; MM is month number 01 to 12 MMMM is full month name january to december (strings depend on culture). Check out MSDN: Custom date and time format strings...

Java - How to Compare Char[] Array with String?

java,string,char,data-type-conversion

The assignment of a character to a String is invalid. You can use a concatenation trick to do it anyway, but that borders on a hack: String[] oneLetter = ""+alphabet[i]; A better approach would be to check that letter has the length of 1, and that its only character matches...

What does rank mean in relation to type conversion?

c++,type-conversion,implicit-conversion,data-type-conversion,rank

The 4.13 section says that Every integer type has an integer conversion rank defined as follows: — No two signed integer types other than char and signed char (if char is signed) shall have the same rank, even if they have the same representation. — The rank of a signed...

How does the ternary operator evaluate the resulting datatype?

java,data-type-conversion,ternary-operator

Isn't the return type for a ternary expression evaluated at runtime? No, absolutely not. That would be very contrary to the way Java works, where overload resolution etc is always performed at compile-time. What would you expect to happen if you hadn't passed the result to a method, but...

R: Convert hours:minutes:seconds

r,datetime,data-type-conversion

Here are some alternatives: 1) The chron package has a "times" class in which 1 unit is a day and there are 60 * 24 minutes in a day so: library(chron) 60 * 24 * as.numeric(times(Time.Training)) giving: [1] 60 45 30 90 1a) Another approach using chron is the following...

Insert dates from textbox without error if a date is missing [closed]

c#,sql,sql-server,date,data-type-conversion

You should have some kind of validation on your input. If it doesn't look like a date, throw an error. You can use DateTime.TryParse() for this. DateTime date = new DateTime(); if(DateTime.TryParse(textBox1.Text, out date)) { //The text is a valid date //Insert it } If you need a specific format...

Split uint16_t in bits in C

c,data-type-conversion

Leaving aside that you can't split 8 bits into 16 (I'm going to assume you actually have a uint16_t, since that makese sense here), what you want to is called a mask. Let's say your 16 bit value is stored in variable "value" To get the first (most significant) 5...

Cast error in C# for datatype short [duplicate]

c#,data-type-conversion

Modify the following, short key = i + (short)1; to short key = (short) (i + (short)1); The reason being, any additions of short + short might overflow short range. and hence this requires a explicit casting....

how to double values alphabet to numbers?

java,double,data-type-conversion

Assuming your value in scientific notation is a String, you can do this: Double d = Double.parseDouble("3.2179465E7"); DecimalFormat df = new DecimalFormat("#.00"); System.out.println(df.format(d)); ...

Insert character to a number datatype column

sql,database,oracle,oracle11g,data-type-conversion

While I advise not to proceed like this as this could be rife for errors and a possible maintenance nightmare, I do like a challenge and have been forced to do some screwy things myself in order make some vendor's bizarre way of doing things work for us so I...

Remove line breaks “\n” in R

r,date,line-breaks,data-type-conversion,factors

You could specify na.strings and stringsAsFactors=FALSE in the read.csv/read.table. (I changed the delimiter to , and saved the input data) stk <- read.csv('Akash.csv', header=TRUE, stringsAsFactors=FALSE, sep=",", na.strings="\\N") head(stk,3) # sku Stockout_start Stockout_End create_date #1 0BX-164463 <NA> 1/29/2015 11:35 1/29/2015 11:35 #2 0BX-164463 2/11/2015 18:01 <NA> 2/11/2015 18:01 #3 0BX-164464 <NA>...

Role of qw and math manipulation in Perl

arrays,perl,math,data-type-conversion

Quote Words: my @xs = qw/22.595451 20.089094 17.380813 15.091260 12.477935 10.054821 7.270003 4.804673 4.728526 4.619254 4.526920 4.418416 4.321419 4.219890 4.123336 4.009777 3.912648 3.804183 3.705847 3.597756 3.512301 3.393413 3.301963 3.196725 3.098560 3.007482 2.899825 2.801002 2.688680 2.598862 2.496139 2.393526 2.282183 2.190449 2.084530 1.987778 1.877562 1.788788 1.678473 1.578123 1.467071 1.373372 1.283629 1.176670 1.071805...

Python: list vs. np.array: switching to use certain attributes

python,arrays,list,numpy,data-type-conversion

A numpy array: >>> A=np.array([1,4,9,2,7]) delete: >>> A=np.delete(A, [2,3]) >>> A array([1, 4, 7]) append: >>> A=np.append(A, [5,0]) >>> A array([1, 4, 7, 5, 0]) sort: >>> np.sort(A) array([0, 1, 4, 5, 7]) index: >>> A array([1, 4, 7, 5, 0]) >>> np.where(A==7) (array([2]),) ...

What is the difference between these data type conversions? [duplicate]

c#,data-type-conversion

These are two very similar operations - but with different results (in some cases). (int) is a Casting Operator. Operators are used for various things, such as Addition, Subtraction, and Bitwise operations. A conversion operator is used to implicitly(implicit), or explicitly(explicit) convert one type to another. This is an example...

Take space separated input having different data types

python,data-type-conversion

Here you go, use raw_input in python 2 (and input in python 3): >>> inp = raw_input("Enter space separated values of form 'a b 2 5' \n") Enter space separated values of form 'a b 2 5' a b 2 5 >>> vars = [int(i) if i.isdigit() else i for...

how to change a table column datatype in a view in postgresql

postgresql,data-type-conversion

You can specify your view just like you'd specify any other query without needing to change the underlying table types. Here's a Fiddle with your example. CREATE TABLE mytable (length INTERVAL); INSERT INTO mytable (length) VALUES (INTERVAL '1 minute'); CREATE VIEW myview AS SELECT to_char(length, 'yy-mm-dd HH24:MI:SS.MS') AS length FROM...

Convert byte[] to char[]. The encoding is UTF-16

java,character-encoding,bytearray,data-type-conversion,utf-16

You can try this: byte[] b = ... char[] c = new String(b, "UTF-16").toCharArray(); From String(byte[] bytes, String charsetName): Constructs a new String by decoding the specified array of bytes using the specified charset. ...

SQL Select Query Not Selecting [duplicate]

c#,sql,syntax,data-type-conversion

After retrieving the data from the database, you have to Read it: while (myReader.Read()) { Console.Out.WriteLine(myReader[5].ToString()); } You can see an example on MSDN. A couple other notes: If myReader[5] might be null, then consider using Convert.ToString(myReader[5]). That'll return an empty string instead of throwing an exception. If you're using...

why is it printing 255

c,data-type-conversion

Up to the representation of a, you are correct. However, the %d and %u conversions of the printf() function both take an int as an argument. That is, your code is the same as if you had written int main() { unsigned char a = -1; printf("%d", (int)a); printf("%u", (int)a);...

Why is Entity Framework passing a parameter as DECIMAL(5,0) for a column defined with NUMERIC(19)?

sql-server,entity-framework,precision,data-type-conversion,sqldatatypes

(@p__linq__0 decimal(5,0)) is the Precision of the parameter value your provided. For example, decimal number = 12345m; var result = context.MyTables.Where(x => x.Number == number).ToList(); Then the query will be like this - exec sp_executesql N'SELECT [Extent1].[Id] AS [Id], [Extent1].[Number] AS [Number] FROM [dbo].[MyTable] AS [Extent1] WHERE [Extent1].[Number] = @p__linq__0',N'@p__linq__0...

SSIS Import a date and time from a txt to a table datetime

sql-server-2008,datetime,ssis,data-type-conversion,data-conversion

I solved it Myself. Thank you for your suggestion gvee but the way I did it is way easier. In the Flat File Source when making a new connection in the advanced tab I fixed all the data types according to the table in the database EXCEPT the column with...

How do I pass data through multiple functions and call them correctly in main?

c++,function,scope,main,data-type-conversion

You are doing it wrong. You should read about function signature and passing arguments. You have defined weight as a function that doesn't take any arguments double weight() { //...} but you are calling it with some parameter userWeight in main function weight(userWeight); and this parameter in addition is not...

Mapping hibernate datatypes to output from stored procedure of mixed types

java,hibernate,data-binding,data-type-conversion,java-stored-procedures

I have resolved such a problem using Hibernate Result Transformer functionality. You just need to extend SQL query in the next way: select RES1 as PROP1, RES2 as PROP2 from Table (select sp_MyProcedure(?) from dual) And then create result POJO: class MyProcRes { public String getPROP1() {} public void setPROP1(String...

How to change data type of a column in an SQL table from integer to decimal

sql,sql-server,integer,decimal,data-type-conversion

Easy - just run this SQL statement ALTER TABLE dbo.Budget ALTER COLUMN ROE DECIMAL(20,2) -- or whatever precision and scale you need..... See the freely available MSDN documentation on what exactly the precision, scale and length in decimal numbers are and what ranges of values are possible...

MATLAB : Alphanumeric character string extraction

matlab,char,data-type-conversion

Ok I'm not entirely sure about whether you need letters all the time, but here regular expressions would likely perform what you want. Here is a simple example to help you get started; in this case I use regexp to locate the numbers in your entries. clear %// Create dummy...

How to convert Tiff to IMG (ERDAS) format using R programming?

r,image,tiff,data-type-conversion

And here is dickoa's solution within a loop: library(raster) input <- list.files(pattern='tif$') output <- gsub("tif", "img", input) for (i in seq(along=input)) { r <- raster(input[i]) # using "2 byte unsigned integer" data type r <- calc(r, fun = function(x) x * 2, datatype='INT2U', filename = output[i]) } ...

SQL Server 2012 How to change the data type of a column from bit to datefield?

datetime,sql-server-2012,bit,data-type-conversion,sqldatatypes

you get this error because DF____Person__onvac__59062A42 sql object Depends on onvacation column. You can Find Dependency of Person table by Right Click-->View Dependancy remove that dependent object and try to alter column...

Possible lossy conversion from int to byte Java

java,byte,data-type-conversion

Actually you are trying to convert an int to byte here: Byte byt=new Byte(00000001); If you want to call the function you could do this, using a cast: Byte byt=new Byte((byte)1); Hope it helps....

Additional non-parsable characters are at the end of the string

c#,string,type-conversion,data-type-conversion,formatexception

hexdigits: A sequence of hexadecimal digits from 0 through f, or 0 through F. It won't parse your X at the end....

Converting (Maybe a, b) to Maybe (a,b)

function,haskell,tuples,data-type-conversion,maybe

You could also use Bitraversable: bitraverse id pure :: (Bitraversable t, Applicative f) => t (f c) d -> f (t c d) which specializes to bitraverse id pure :: (Maybe a, b) -> Maybe (a, b) ...

Correctly store content of file by line to array and later print the array content

c,arrays,data-type-conversion,fgets

I think you need to say something like file_data[data_index++] = atoi(line);...

SSIS Blank Int Flat File Fail on Load

sql-server,ssis,null,data-type-conversion

I ended up using the approach from this blog post: http://www.proactivespeaks.com/2012/04/02/ssis-transform-all-string-columns-in-a-data-flow-stream/ to handle all of the null and blank columns via a script task and data conversion....

(Oracle) convert date string to datetime

sql,oracle,datetime,data-type-conversion,timestamp-with-timezone

It is stored in a column with data type VARCHAR2(100 BYTE). First of all, you should never ever store DATE/TIMSTAMP as string. It is a database design flaw. Anyway, you could convert it to TIMESTAMP WITH TIMEZONE. For example, SQL> SELECT to_timestamp_tz('2015-06-04T02:58:00.134+08:00', 2 'YYYY-MM-DD"T"HH24:MI:SS.FF TZH:TZM') 3 AT TIME ZONE...

Precision, Rounding, and data types in XSLT2.0

xslt,decimal,rounding,xslt-2.0,data-type-conversion

Assuming there is no schema involved, the typed value of the element InvoiceAmount is xs:untypedAtomic - which essentially means a string, but one that adapts itself to the context in which it is used. If you do an explicit conversion to xs:decimal, the untypedAtomic value "-62.84" will convert exactly. If...

Technical things about conversion from []byte and string in Golang

memory-management,go,data-type-conversion

Yes in both cases. String types are immutable. Therefore converting them to a mutable slice type will allocate a new slice. See also http://blog.golang.org/go-slices-usage-and-internals The same with the inverse. Otherwise mutating the slice would change the string, which would contradict the spec....

Assembly Language - Converting Two's Complement Hexadecimal to its Base 10 Equivalent

assembly,hex,decimal,data-type-conversion,base

(@chathux hints at the answer). You have a value X==FFFC0888_16. When you converted X to 0003F778 (by taking "twos complement"), you did so because you (should have) thought the X value was "negative" (the sign bit is set). The decimal value you produced 259960 is the correct magnitude, that is...

dividing a decimal type in SQL Server results in unnecessary trailing zeros

sql-server,tsql,decimal,data-type-conversion,sqldatatypes

SQL server does integer arithmetic, to force it to use numeric, you can multiply it by 1.0 No need of using convert twice. This gives 89456.123 with out double convert. select convert(decimal(11,3),89456123*1.0/1000) as TotalUnits ...

Changing datatype lead to change the result

sql-server,tsql,data-type-conversion

When you CAST your Productid with value say 123 using CAST(Productid as VARCHAR(10)), it's converted to variable character type which does not have padding of spaces at the end. However If you use CHAR(10), it will pad spaces at the end of 123 and you'll get '123 ' with 7...

Why converting numpy.ndarray to custom data type using numpy.ndarray.astype multiplies my data?

python,arrays,numpy,data-type-conversion,custom-data-type

np.array([tuple(py_list)], custom_type) produces array([(2013, 8, 0.6552734375)], dtype=[('YEAR', '<u2'), ('DOY', '<u2'), ('REF', '<f2')]) Data for structured arrays are supposed to a list of tuples (orjust one tuple). Notice how the values are displayed. [(...)]. There may be a way of doing this with astype, but it is tricky. Also,notice what NumPy_array...

Parse a date from a text file and convert the month to a number

java,string,int,data-type-conversion

Here is a very simple example to process your file and split the string line and obtain the date object. public class FileReaderExample { public static void main(String[] args) { File file = new File("d:\\text.txt"); try { BufferedReader br = new BufferedReader(new FileReader(file)); String line; int lineNo = 1; while...

Convert a date to a day number (monday = 1, tuesday = 2) in R

r,date,numbers,rstudio,data-type-conversion

You can do this easily with lubridate although it indexes Sunday as '1'. So since March 1, 2014 was a Saturday it would return '7' library(lubridate) wday(mdy("3-1-2014")) [1] 7 ...

One array, multiple types

c++,arrays,data-type-conversion

Since you are restricted to using only the standard library you will need to either implement a solution yourself or use an existing easily adaptable solution. What you are looking for is referred to as a tagged union or variant. This is a data structure that contains a union to...

Why I receive warning in objectForKey method?

objective-c,nsdictionary,data-type-conversion

Your countRowsInSection: seems to expect its argument to be a long. But you're sending it an object (probably an NSNumber). If that is the case, the following will work: [objectp.methodA countRowsInSection:[[tableSections objectForKey:[NSString stringWithFormat:@"%ld", sect] longValue]]]; ...

Java: handle time-expressions

java,types,data-type-conversion

How about doing that by hand. Just create a wrapper class and make an enum with values AfterNoon, Morning, ... And provide a constructor that takes a Date object and code the logic as you want. Class DateWrapper { private Date date; private DayTime dayTime; public DateWrapper (Date date){ ......

Convert string stored as binary back to string

c#,sql-server,string,binary-data,data-type-conversion

The nvarchar value is converted to a binary value where each character is two bytes. You can convert it already when you read it from the database: select convert(nvarchar(max), QRCodeData) from dbo.QRCode ... Or you can use the UTF-16 encoding to convert the data in C#: string qrCodeLink = Encoding.Unicode.GetString(qrCodeData);...

When does a data type means more than its storage space to the compiler?

c++,c,types,data-type-conversion

You are ultimately asking how compilers work and how they handle type information and data representation. The answer here is broad and there are multiple approaches: Some compilers carry out type erasure, so that there is no information about what type a particular variable is when it is in memory....

Comparing linkedHashMap values to strings in Java

java,data-type-conversion,linkedhashmap

Here's the official tutorial on Generics in Java. Read it. You've used a parameterized type with sections, but stopped using it after Set set = sections.entrySet(); Iterator iter = set.iterator(); Map.Entry me = (Map.Entry)iter.next(); These are raw types and should rarely be used. Parameterize them correctly (and change the type...

Change datatype of entire database SQL

sql,sql-server-2012,data-type-conversion

You can use the internal system tables that store the metadata about the tables and columns to generate your ALTER TABLE statements. SELECT 'ALTER TABLE ' + OBJECT_NAME(c.object_id) + ' ALTER COLUMN ' + c.name + ' DECIMAL(30,10);' AS sqlCommand FROM sys.columns AS c INNER JOIN sys.types AS t ON...

What is bit data type equivalent in DBML?

sql-server,data-type-conversion,sqldatatypes,dbml

From the MSDN reference http://msdn.microsoft.com/en-us/library/ms177603.aspx, for bit on MSSQL "The string values TRUE and FALSE can be converted to bit values: TRUE is converted to 1 and FALSE is converted to 0." Going by that logic, I would use boolean for your mapping. NOTE: This is a pretty commonly discussed...

Single Function Call to return any possible data type

c#,function,data-type-conversion

Yes, it is called generics: public T GetValue<T>(Object value) { if (value == DbNull.Value) { return default(T); } return (T)value; } Then call it like this: string s = GetValue<string>(DataRow["CustomerName"]); Or, as Tim Schmelter suggested, in this case you could use: DataRow.Field<string>("CustomerName"); ...

Converting data from a csv file into numpy array issue

python,csv,numpy,data-type-conversion

Your date format is incorrect, it needs to be year,month and day "%Y%m%d", you also cannot have a datetime object and floats in your array but using a structured array allows you to have mixed types. If mdates returns a float using the correct format should work again providing you...

How to convert type of a variable when using JuMP

type-conversion,data-type-conversion,julia-lang,julia-jump

The problem is that the second @defVar(m, 0 <= x <= 1, Bin) actually creates a new variable in the model, but with the same name in Julia. There currently isn't a good way to change a variable from continuous to binary, but you can do setLower(x, 0.0) setUpper(x, 1.0)...

convert column type in postgres without losing data

postgresql,timestamp,data-type-conversion

Try this: update mytable set last_updated_att='today'::timestamp+last_updated_at from mytable;        ...

ORA-06532: Subscript outside of limit

plsql,sql-update,data-type-conversion,varray

Initialize v_initial to 1 instead of 0. Varray indexes start at one. Also, here's another technique for committing every X records you may want to consider for simplicity: commit_count_const CONSTANT number := 5000; -- commit every 5000 v_loop_counter := 0 ... FOR i in... UPDATE... v_loop_counter := v_loop_counter + 1;...

sql BIT to Java [closed]

java,sql-server,jdbc,types,data-type-conversion

You can call getBoolean directly and let it take care of all the casting/coverting: result.add(rs.getBoolean("columnName")); ...

how to convert a factor variable into a numeric - using R

r,variables,numeric,data-type-conversion,recode

First, here's why you would have to convert to character before converting to numeric: Lets say we have a factor that contains a handful of numbers x = factor(c(1,2,7,7)) you can inspect how this is represented in R like so: unclass(x) #> [1] 1 2 3 3 #> attr(,"levels") #>...

Addition on two blank objects or blank arrays in javascript

javascript,data-type-conversion

Expected results When you are adding two arrays, everything works as expected: [] + []//output'' Converting [] to a primitive first tries valueOf() which returns the array itself (this): var arr = []; arr.valueOf() === arr true As that result is not a primitive, toString() is called next and returns...

Which data type in Racket is this?

scheme,racket,data-type-conversion

It's a list of symbols (not strings). It's the same as this: (list 'ace 'spade 'king 'queen) For more details please check the documentation. Notice that a list of strings would look like this: '("ace" "spade" "king" "queen") Or equivalently: (list "ace" "spade" "king" "queen") ...

DateTime format string for invalid Format string

c#,datetime,format,data-type-conversion

If you assume that all the letters inserted in your format are either separators or letters that should be converted to a DatePart, you can check if after converting the date you still have non separator chars that were not converted, as follows: public static class DateTimeExtension { public static...

JavaScript beginner troubles with quotation marks

javascript,variables,data-type-conversion

In Javascript (and most other languages), you write a string by putting a sequence of characters between a pair of quote characters. So a string containing abc is written as "abc" If you want one of the characters in the string to be a quote character, you have to escape...

Insert decimal value into Currency Access field

c#,ms-access,data-type-conversion

Your issue appears to be a limitation of the Access ODBC driver when dealing with Currency fields using System.Data.Odbc in .NET. An OdbcDataReader will return those fields as System.Decimal (if the value is not NULL), but System.Data.Odbc apparently won't accept a System.Decimal parameter for a Currency field. As a workaround...

Error when updating SQL from datatable using adapter.update()

c#,datagridview,datatable,data-type-conversion,sqlcommand

The following line will give an error if the database field is an "int": command.Parameters.AddWithValue("@DWFieldScale", "DWFieldScale"); It will give an error because you are passing as value to the field a string "DWFieldScale". The idea behind the command.Parameters is the control to make any conversion required for you. See this:...

Arduino data type confusion. Have string, need const char?

c,arduino,data-type-conversion

Convert the String into a char array first: size_t len = myString.length(); char buf[len+1]; // +1 for the trailing zero terminator myString.toCharArray(buf, len); and then you can pass buf: bool ok = network.write(header,buf,strlen(buf)); ...

Bytes form nginx logs is mapped as string not number in elasticsearch

nginx,elasticsearch,logstash,data-type-conversion

You're on the right track with (?:%{NUMBER:bytes:long}|-), but "long" isn't a valid data type. Quoting the grok documentation (emphasis mine): Optionally you can add a data type conversion to your grok pattern. By default all semantics are saved as strings. If you wish to convert a semantic’s data type, for...