0

Subject: Variables in Hocon, String concatenation and date substitution.

Current Use case: I am trying to get a simple string with a date like the following via the Hocon Config: "myElasticSearchIndex_25Jan2018"

What have I tried in the hocon:

   todayDate {
      day =${time.day}
      month=${time.month}
     }

C#

     var todayDate = config.GetString("todayDate.day");

Error: An unhandled exception of type 'System.FormatException' occurred in Akka.dll: Additional information: Unresolved substitution: time.day

Question: How do I do a gatedate()? or getmonth() or getday() via substitution on the hocon?

The documentation is not clear on this: https://github.com/lightbend/config/blob/master/HOCON.md#units-format

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
  • Sorry, but could you be more precise? If you're using `${time.day}` it means, that your'e trying to substitute value for current key (here `todayDate.day`) with a value from another HOCON path (here: `time.day`). The error was thrown since probably there's no such path in your HOCON config. – Bartosz Sypytkowski Jan 25 '18 at 14:26
  • ${time.day} means I am trying to retrive the current "day" on the current as simular to sql or c# date.now.day. As per Hocon documentation referenced it seems like there is a way to reference time for use on your local variables. – Lizo Matala Jan 26 '18 at 08:44
  • ${} in HOCON means, that you're referencing to the value provided in another hocon path specified between the brackets. – Bartosz Sypytkowski Jan 26 '18 at 10:18
  • Ok- i understand that but how do you refer to a enviroment variable like the date one on the document: https://github.com/lightbend/config/blob/master/HOCON.md#units-format – Lizo Matala Jan 26 '18 at 11:26
  • HOCON is a configuration format, not a scripting language. How would you refer to date on the document from XML, JSON or YAML file? You can include this value by constructing a HOCON configuration string at runtime using your own code. – Bartosz Sypytkowski Jan 29 '18 at 12:22
  • did you go to the Hocon documentation link as stated above? In Nlog config you can specify the date of file format in your property of your xml properties – Lizo Matala Jan 31 '18 at 11:16
  • "In Nlog config you can specify the date of file format in your property of your xml properties" - it's a property of NLog (library) not XML (configuration format) by itself. Same for HOCON. The link to the documentation also doesn't prove your words. It only informs about how value suffixes make easier to interpret the resolved values. – Bartosz Sypytkowski Jan 31 '18 at 16:04

0 Answers0