SageTV Community

SageTV Community (http://forums.sagetv.com/forums/index.php)
-   SageTV Studio (http://forums.sagetv.com/forums/forumdisplay.php?f=34)
-   -   How to display Date as MM/dd/YY (zero pad) (http://forums.sagetv.com/forums/showthread.php?t=66631)

graywolf 01-04-2021 01:00 PM

How to display Date as MM/dd/YY (zero pad)
 
In Studio, I have:
DateFormat("MM/dd/yy", StartTime)

It is displaying dates like 12/1/20 and 1/3/21 but I want it to be 12/01/20 and 01/03/21

Per the API it says:
DateFormat
public java.lang.String DateFormat(java.lang.String Format,
java.lang.Object Date)
Returns a formatted date string for the specified Date.
Parameters:
Format - null if SageTV's default date format should be used, otherwise use a formatting string as specified in java.text.SimpleDateFormat
Date - either a java.util.Date object or a long which corresponds to the date
Returns:
the date formatted string

From my understanding, SimpleDateFormat is suppose to be displaying MM/dd/yy as 12/01/20, 01/03/21, etc

What am I missing?

wnjj 01-04-2021 10:56 PM

I looked into the DateFormat code and there's special handling in there for localization:

Quote:

// Replace M/d with the appropriate representation for this Locale
In the code (https://github.com/google/sagetv/blo...lity.java#L249), it uses a regular expression to match on M or MM followed by /, followed by d or dd and replaces it with a localized version using java.text.DateFormat.SHORT.

I don't claim to understand all of this completely but it's possible that what you are trying to do won't work.

graywolf 01-05-2021 07:01 AM

Thanks. That explains it.
Changing to MM-dd-yy works to have the padded zeros i.e. 12-01-20 and 01-03-21


All times are GMT -6. The time now is 11:21 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.
Copyright 2003-2005 SageTV, LLC. All rights reserved.