Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Conversions in Java

Reply
Thread Tools

Conversions in Java

 
 
Panoramix
Guest
Posts: n/a
 
      05-21-2013
Someone has a good introduction to conversions of values in Java?

I am working in a project that I need to use this and I'm having some trouble about this.


Thanks!
 
Reply With Quote
 
 
 
 
Arne Vajh°j
Guest
Posts: n/a
 
      05-21-2013
On 5/21/2013 11:23 AM, Panoramix wrote:
> Someone has a good introduction to conversions of values in Java?
>
> I am working in a project that I need to use this and I'm having some trouble about this.


What type of conversions?

Arne


 
Reply With Quote
 
 
 
 
Stefan Ram
Guest
Posts: n/a
 
      05-21-2013
Panoramix <(E-Mail Removed)> writes:
>Someone has a good introduction to conversions of values in Java?


There are no special books about the conversions of values
in Java, but the topic is treated in every good Java text book.

>I am working in a project that I need to use this and I'm having some trouble about this.


Possibly, you might want

java.lang.Double.valueOf( yourText )

 
Reply With Quote
 
Arved Sandstrom
Guest
Posts: n/a
 
      05-21-2013
On 05/21/2013 12:34 PM, Stefan Ram wrote:
> Panoramix <(E-Mail Removed)> writes:
>> Someone has a good introduction to conversions of values in Java?

>
> There are no special books about the conversions of values
> in Java, but the topic is treated in every good Java text book.


And the language spec and type APIs.

>> I am working in a project that I need to use this and I'm having some trouble about this.

>
> Possibly, you might want
>
> java.lang.Double.valueOf( yourText )
>

Good point, both Arne and Stefan - it may not be simply implicit numeric
type conversions referred to here, but also parsing string into numeric,
etc etc.

AHS
 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      05-21-2013
Stefan Ram wrote:
> Panoramix writes:
>> Someone has a good introduction to conversions of values in Java?


Arne asked "What type of conversions?" Here is some general information about various
conversion types:

http://docs.oracle.com/javase/tutori...onverting.html
http://docs.oracle.com/javase/tutori...utoboxing.html
http://docs.oracle.com/javase/tutori...ymorphism.html
http://docs.oracle.com/javase/tutori...o/scanfor.html
http://docs.oracle.com/javase/tutori...aceAsType.html

If you read the Java Language Specification (JLS) you will get the normative definitions
for various conversions:
http://docs.oracle.com/javase/specs/...tml/jls-5.html

If you mean various formatting or string conversions, as Stefan conjectured, then you
should look at the Javadocs for various formatting and string-ish types:
http://docs.oracle.com/javase/7/docs...va.lang.String, java.lang.Object...)
et al.
http://docs.oracle.com/javase/7/docs...l/Scanner.html
http://docs.oracle.com/javase/7/docs...xt/Format.html
and related types

> There are no special books about the conversions of values
> in Java, but the topic is treated in every good Java text book.
>
>> I am working in a project that I need to use this and I'm having some trouble about this.

>
> Possibly, you might want
>
> java.lang.Double.valueOf( yourText )


There are similar 'valueOf()' methods in the other primitive wrapper classes ('Integer', ...).

Also, GIYF.

--
Lew
 
Reply With Quote
 
Panoramix
Guest
Posts: n/a
 
      05-21-2013
Thanks guys!

I really appreciate.

When I say conversions, I mean every type of conversion!

Thanks for the help
 
Reply With Quote
 
Eric Sosman
Guest
Posts: n/a
 
      05-21-2013
On 5/21/2013 6:07 PM, Panoramix wrote:
> Thanks guys!
>
> I really appreciate.
>
> When I say conversions, I mean every type of conversion!


There's a reasonably accurate summary at

<http://docs.oracle.com/javase/specs/jls/se7/html/jls-5.html>

> Thanks for the help


Glad to be of service.

--
Eric Sosman
http://www.velocityreviews.com/forums/(E-Mail Removed)d
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      05-22-2013
On Tue, 21 May 2013 08:23:13 -0700 (PDT), Panoramix
<(E-Mail Removed)> wrote, quoted or indirectly quoted someone
who said :

>Someone has a good introduction to conversions of values in Java?


see http://mindprod.com/applet/converter.html
--
Roedy Green Canadian Mind Products http://mindprod.com
Technological possibilities are irresistible to man.
If man can go to the moon, he will.
If he can control the climate, he will.
~ John von Neumann (born: 1903-12-28 died: 1957-02-08 at age: 53)
 
Reply With Quote
 
Robert Klemme
Guest
Posts: n/a
 
      05-25-2013
On 22.05.2013 00:07, Panoramix wrote:

> When I say conversions, I mean every type of conversion!


Well, then you just need

public interface Converter<F,T> {
T convert(F fromValue);
}

implement all conversions needed plus a smart mechanism to choose the
appropriate one in every case.

Cheers

robert

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
 
Reply With Quote
 
Arved Sandstrom
Guest
Posts: n/a
 
      05-25-2013
On 05/25/2013 06:27 PM, Robert Klemme wrote:
> On 22.05.2013 00:07, Panoramix wrote:
>
>> When I say conversions, I mean every type of conversion!

>
> Well, then you just need
>
> public interface Converter<F,T> {
> T convert(F fromValue);
> }
>
> implement all conversions needed plus a smart mechanism to choose the
> appropriate one in every case.
>
> Cheers
>
> robert
>

JSF javax.faces.convert.Converter. You've got to do the custom work
and the mechanism is explicit, but still...

A fair few ESBs (enterprise service buses) also have what they call
transformers (converters) and often a registration/auto-discovery
mechanism. For example, in Java-based ESBs - which is most of them - you
might have a message which encounters a processing component, which by
entry point resolution, expects a payload of class X and to return a
payload of class Y (null is acceptable): the ESB will consult a list of
X<->Y converters that it knows about, and select the best converter
according to a rule set.

AHS
--
When a true genius appears, you can know him by this sign:
that all the dunces are in a confederacy against him.
-- Jonathan Swift
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mail database conversions? Wheaty Firefox 8 08-07-2005 03:32 AM
Pointer conversions and Data types conversions vb@gmail.com C Programming 10 08-05-2005 09:51 AM
Type Conversions Weaam Attallah VHDL 1 11-18-2003 10:13 AM
Access db to ado.net data type conversions? Brian Henry ASP .Net 2 10-13-2003 02:38 PM
conversions Max VHDL 0 09-11-2003 07:32 AM



Advertisments