0

I am converting python to java but I do not know python (I know java).

Here is the python:

localtime = time.localtime(time.time())

and it is being used in this way:

policyname = 'LLC-Uninstall-D%s%s%s-T%s%s%s%s' % (localtime[0], localtime[1], localtime[2], localtime[3], localtime[4], localtime[5], localtime[6]) 

I would like to do the same thing in Java. Is this possible?

1

1 Answer 1

2

Sure, use SimpleDateFormat:

SimpleDateFormat df = new SimpleDateFormat("'LLC-Uninstall-D'yyyyMMdd-HHmmss");
String formatted = df.format(new Date());

The documentation for the formatting symbols can be found at the JavaDoc Page for SimpleDateFormat, you can use that to configure the exact string produced to meet your needs.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.