Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

How do I apply a format to a number or date?


  • Please log in to reply
3 replies to this topic

#1 Mack

Mack

    New Member

  • Members
  • Pip
  • 2 posts

Posted 15 January 2013 - 10:58 AM

OK, I'm stumped.

 

I've got a Netduino Plus 2 measuring and logging to an SD card timestamped temperatures via a couple of DS18B20's.  I want to add an LCD to display the current values.  I've got the LCD bit working fine except that I want to display date in the format dd/mm/yy (the current format is mm/dd/yyyy) and limit the temperature display to one decimal.  I'm working in C#.

 

Apart from doing some (messy) manipulations to get the data in the right format to display, is there any simple way via a library or similar?

 

This particular newb would really appreciate some guidance.

 

Thanks in advance.

 

 



#2 JerseyTechGuy

JerseyTechGuy

    Advanced Member

  • Members
  • PipPipPip
  • 870 posts

Posted 15 January 2013 - 11:36 AM

These are pretty basic C# concepts and not specific to Netduno.  You can simply google "Formatting Strings in C#".

 

For a date -->  DateTime.Now.ToString("dd/MM/yy").ToString();

 

For limiting Decimal Places --> temperature.ToString("F1");

 

Here are good resources on string formatting:

 

http://msdn.microsof...ing.format.aspx

 

http://msdn.microsof...y/dwhawy9k.aspx



#3 Mack

Mack

    New Member

  • Members
  • Pip
  • 2 posts

Posted 15 January 2013 - 10:16 PM

Thanks Dave.  Who knew it was that simple?  This is my first C# project and I was looking for all the wrong things on Google.

 

Cheers! 



#4 JerseyTechGuy

JerseyTechGuy

    Advanced Member

  • Members
  • PipPipPip
  • 870 posts

Posted 16 January 2013 - 03:27 AM

Thanks Dave.  Who knew it was that simple?  This is my first C# project and I was looking for all the wrong things on Google.

 

Cheers! 

 

No Problem. Happy formatting! :)






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.