FAQ  •  Register  •  Login

Need Java/Groovy help

<<

Illico

User avatar

DLNA master

Posts: 4646

Joined: Fri Jul 23, 2010 8:08 am

Location: France

Post Sun Jan 15, 2012 10:14 am

Need Java/Groovy help

I'm working on a groovy plugin but I need Java/Groovy dev help.
I googled and try lots of source code without success..remember I'm not a Java dev ;)

I would like to create a hexadecimal String like this "4f1191a5" from a Integer TimeStamp like this System.currentTimeMillis().

Any Ideas?

  Code:
      def dtime = System.currentTimeMillis()
      println "dtime : " + dtime.toString()
      
      def dtimeexample = Integer.parseInt('4f1191a5', 16)
      println "dtimeexample(4f1191a5) : " + dtimeexample.toString()


dtime : 1326622399078
dtimeexample(4f1191a5) : 1326551461
Illico
Sony 2010 KDL-46EX501 | BDP-S373 | SMP-N100 | Windows 8-i7 | Network DD HD-CE1.5TLU2 | Livebox2-UHD86 | ServiiDroid | ServiiGo | BubbleUPnP
Serviio beta tester - Moderator
<<

zip

User avatar

Serviio developer / Site Admin

Posts: 17160

Joined: Sat Oct 24, 2009 12:24 pm

Location: London, UK

Post Sun Jan 15, 2012 11:35 am

Re: Need Java/Groovy help

Try this:

  Code:
String.format("%X", dtime)
<<

Illico

User avatar

DLNA master

Posts: 4646

Joined: Fri Jul 23, 2010 8:08 am

Location: France

Post Sun Jan 15, 2012 11:59 am

Re: Need Java/Groovy help

Great Zip!

  Code:
      def dtime = (System.currentTimeMillis()/1000).toInteger()
      def stime = String.format("%X", dtime)
      println "dtime($stime)          : " + dtime
      
      def dtimeexample = Integer.parseInt('4F12A817', 16)
      println "dtimeexample(4F12A817) : " + dtimeexample.toString()


dtime(4F12BF59) : 1326628697
dtimeexample(4F12A817) : 1326622743


Thanks
Illico
Sony 2010 KDL-46EX501 | BDP-S373 | SMP-N100 | Windows 8-i7 | Network DD HD-CE1.5TLU2 | Livebox2-UHD86 | ServiiDroid | ServiiGo | BubbleUPnP
Serviio beta tester - Moderator

Return to Plugin development

Who is online

Users browsing this forum: No registered users and 1 guest

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.