Looks like both the question and accepted answer ignore time zone, which is probably a problem.
This work is much easier with Joda-Time or the new java.time.* package in Java 8. You said you have long
primitive value, so let's start there assuming it represents milliseconds from Unix epoch (1970). No need to deal with creating or parsing string representations of the date at all. Joda-Time offers many points of access to year, month, etc. numbers and names. And Joda-Time localizes the names to Swedish or English.
The date style code is a pair of characters. The first character is the date style, and the second character is the time style. Specify a character of 'S' for short style, 'M' for medium, 'L' for long, and 'F' for full. A date or time may be omitted by specifying a style character '-'.
long input = DateTime.now().getMillis();
DateTimeZone timeZone = DateTimeZone.forID( "Europe/Stockholm" );
DateTime dateTime = new DateTime( input, timeZone );
int year = dateTime.getYear();
int month = dateTime.getMonthOfYear(); // 1-based counting, 1 = January. Unlike crazy java.util.Date/Calendar.
int dayOfMonth = dateTime.getDayOfMonth();
int hourOfDay = dateTime.getHourOfDay();
int minuteOfHour = dateTime.getMinuteOfHour();
java.util.Locale localeSweden = new Locale( "sv", "SE" ); // ( language code, country code );
String monthName_Swedish = dateTime.monthOfYear().getAsText( localeSweden );
String monthName_UnitedStates = dateTime.monthOfYear().getAsText( java.util.Locale.US );
DateTimeFormatter formatter_Sweden = DateTimeFormat.forStyle( "LM" ).withLocale( localeSweden ).withZone( timeZone );
DateTimeFormatter formatter_UnitedStates_NewYork = DateTimeFormat.forStyle( "LM" ).withLocale( java.util.Locale.US ).withZone( DateTimeZone.forID( "America/New_York" ) );
String text_Swedish = formatter_Sweden.print( dateTime );
String text_UnitedStates_NewYork = formatter_UnitedStates_NewYork.print( dateTime );
DateTime dateTimeUtcGmt = dateTime.withZone( DateTimeZone.UTC );
Dump to console…
System.out.println( "dateTime: " + dateTime );
System.out.println( "monthName_Swedish: " + monthName_Swedish );
System.out.println( "monthName_UnitedStates: " + monthName_UnitedStates );
System.out.println( "text_Swedish: " + text_Swedish );
System.out.println( "text_UnitedStates_NewYork: " + text_UnitedStates_NewYork );
System.out.println( "dateTimeUtcGmt: " + dateTimeUtcGmt );
When run…
dateTime: 2014-02-16T07:12:19.301+01:00
monthName_Swedish: februari
monthName_UnitedStates: February
text_Swedish: den 16 februari 2014 07:12:19
text_UnitedStates_NewYork: February 16, 2014 1:12:19 AM
dateTimeUtcGmt: 2014-02-16T06:12:19.301Z