What should I do to record audio files with Java that is not .wav, .au, or .aif?

I want to record .ogg or .mp3

Here's the line that specifies the extension in the code:
Java Code:
AudioFileFormat.Type targetType = AudioFileFormat.Type.WAVE;
Should I convert it after the record or there's some other way?

Thanks in advance.