Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: DateTime Convertion To Binary

  1. #1
    Junior Member
    Join Date
    May 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default DateTime Convertion To Binary

    Hi All,
    I am working on Communication Application between C# and Java.
    I want to send DateTime in the Binary Form (As .Net understands) so that it can be read in the C# end with the Method DateTime.FromBinary((int64)date);
    How can i convert it into this Format.

    Any Help would be Highly Appreciated

    Regards,
    Aamir


  2. #2
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: DateTime Convertion To Binary

    Hello, how exactly is the date stored as binary, is it a long value or a string representing the date or some other way? I've not got much experience with C# myself so I'm not aware how it reads the date and time from binary.

    Also, how do intend to communicate between these two applications? Would it not be clever to use a web service or similar or are you using some other protocol?

  3. #3
    Junior Member
    Join Date
    May 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: DateTime Convertion To Binary

    Thx for reply,
    I am communicating through TCP (Sockets).C# have Builtin Function to read from binary DateTime.FromBinary(int64value) which takes long value and date.ToBinary() to converts to int64 value.
    You can check it on
    DateTime.ToBinary Method (System)
    and
    DateTime.FromBinary Method (System)

    Thx ,
    Regards,
    Aamir

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: DateTime Convertion To Binary

    Everything in a computer is in binary format. Its all bits and bytes. Programs control what those bits and bytes represent.

    What is the format/contents of the bytes that the C# program expects? Given a bit by bit layout, you can create the data in the correct format using Java so that the C# program can extract/convert the data to the Date/Time.

Similar Threads

  1. Binary Search Help
    By OwsumEmam in forum What's Wrong With My Code?
    Replies: 7
    Last Post: March 31st, 2011, 11:01 PM
  2. Binary Search Help!
    By Allicat in forum What's Wrong With My Code?
    Replies: 8
    Last Post: March 15th, 2011, 04:03 PM
  3. Binary Numbers
    By Bido in forum Java Theory & Questions
    Replies: 1
    Last Post: January 6th, 2011, 03:54 PM
  4. need help with binary tree
    By vash0047 in forum Java Theory & Questions
    Replies: 5
    Last Post: July 12th, 2010, 08:23 AM
  5. How to convert float and double data types to binary?
    By rosh72851 in forum Java Theory & Questions
    Replies: 1
    Last Post: October 7th, 2008, 10:45 PM