JayBeeOH

Time Demo (Console App.)

Mar 2nd, 2016
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 2.28 KB | None | 0 0
  1. '------------------------------------------------------------------------------------------
  2. '           Notice of My Copyright and Intellectual Property Rights
  3. '
  4. ' Any intellectual property contained within the program by Joseph L. Bolen remains the
  5. ' intellectual property of the Joseph L. Bolen. This means that no person may distribute,
  6. ' publish or provide such intellectual property to any other person or entity for any
  7. ' reason, commercial or otherwise, without the express written permission of Joseph L. Bolen.
  8. '
  9. '                 Copyright © 2016. All rights reserved.
  10. '        All trademarks remain the property of their respective owners.
  11. '-------------------------------------------------------------------------------------------
  12. ' Program Name:   Time Demo
  13. '
  14. ' Author:         Joseph L. Bolen
  15. ' Date Created:   02 MAR 2016
  16. '
  17. ' Description:    Show how to declare and use only the time portion of the Date or DateTime
  18. '                 datatypes.
  19. '
  20. ' Documentation:  http://pastebin.com/mVC6Cc3r
  21. '
  22. '-------------------------------------------------------------------------------------------
  23.  
  24. Module TimeDemo
  25.  
  26.     Sub Main()
  27.  
  28.         ' Using the Date datatype normally...
  29.  
  30.         'Dim aTime As Date = #yyyy-mm-dd hh:mm:ss# (Or #yyyy-mm-dd hh:mm:ss AM/PM#
  31.         'Dim aTime As Date = #2016-03-02 14:02:00#           ' 3/2/2016 2:02:00 PM
  32.         'Dim aTime As Date = #0001-01-01 14:02:00#           ' 1/1/0001 2:02:00 PM
  33.  
  34.         ' Using the Date datatype with only the time portion...
  35.         ' (Defaults to 01 JAN 0001)
  36.  
  37.         'Dim aTime As Date = #14:02#                         ' 1/1/0001 2:02:00 PM
  38.         'Dim aTime As Date = #2:02 PM#                       ' 1/1/0001 2:02:00 PM
  39.  
  40.         ' Using DateTime datatype normally ...
  41.  
  42.         'Dim aTime As New DateTime(yyyy, hh, dd, hh, mm, ss)
  43.         'Dim aTime As New DateTime(2016, 3, 2, 14, 02, 0)    ' 3/2/2016 2:02:00 PM
  44.         Dim aTime As New DateTime(0001, 1, 1, 14, 02, 0)    ' 1/1/0001 2:02:00 PM
  45.  
  46.         Console.WriteLine(aTime)
  47.         Console.WriteLine(aTime.ToShortTimeString)          ' 2:02 PM
  48.         Console.WriteLine(aTime.ToLongTimeString)           ' 2:02:00 PM
  49.         Console.WriteLine(aTime.ToString("hh:mm tt"))       ' 02:02 PM
  50.  
  51.         Console.ReadLine()
  52.  
  53.     End Sub
  54.  
  55. End Module
Advertisement
Add Comment
Please, Sign In to add comment