public static Date str2dat( String arg0, String arg1, String val ) throws KettleValueException { SimpleDateFormat df = new SimpleDateFormat(); DateFormatSymbols dfs = new DateFormatSymbols(); if ( arg1 != null ) { dfs.setLocalPatternChars( arg1 ); } if ( arg0 != null ) { df.applyPattern( arg0 ); } try { return df.parse( val ); } catch ( Exception e ) { throw new KettleValueException( "TO_DATE Couldn't convert String to Date " + e.toString() ); } }
public Value str2dat( String arg0, String arg1 ) throws KettleValueException { if ( isNull() ) { setType( VALUE_TYPE_DATE ); } else { // System.out.println("Convert string ["+string+"] to date using pattern '"+arg0+"'"); SimpleDateFormat df = new SimpleDateFormat(); DateFormatSymbols dfs = new DateFormatSymbols(); if ( arg1 != null ) { dfs.setLocalPatternChars( arg1 ); } if ( arg0 != null ) { df.applyPattern( arg0 ); } try { value.setDate( df.parse( getString() ) ); setType( VALUE_TYPE_DATE ); setLength( -1, -1 ); } catch ( Exception e ) { setType( VALUE_TYPE_DATE ); setNull(); throw new KettleValueException( "TO_DATE Couldn't convert String to Date" + e.toString() ); } } return this; }
public Value dat2str( String arg0, String arg1 ) throws KettleValueException { if ( isNull() ) { setType( VALUE_TYPE_STRING ); } else { if ( getType() == VALUE_TYPE_DATE ) { SimpleDateFormat df = new SimpleDateFormat(); DateFormatSymbols dfs = new DateFormatSymbols(); if ( arg1 != null ) { dfs.setLocalPatternChars( arg1 ); } if ( arg0 != null ) { df.applyPattern( arg0 ); } try { setValue( df.format( getDate() ) ); } catch ( Exception e ) { setType( VALUE_TYPE_STRING ); setNull(); throw new KettleValueException( "TO_CHAR Couldn't convert Date to String " + e.toString() ); } } else { throw new KettleValueException( "Function DAT2STR only works on a date" ); } } return this; }
/** * Sets localized date-time pattern characters. For example: 'u', 't', etc. * @param newLocalPatternChars the new localized date-time * pattern characters. * @stable ICU 2.0 */ public void setLocalPatternChars(String newLocalPatternChars) { dfs.setLocalPatternChars(newLocalPatternChars); }
/** * Sets localized date-time pattern characters. For example: 'u', 't', etc. * @param newLocalPatternChars the new localized date-time * pattern characters. * @stable ICU 2.0 */ public void setLocalPatternChars(String newLocalPatternChars) { dfs.setLocalPatternChars(newLocalPatternChars); }
@Override public void setLocalPatternChars(String newLocalPatternChars) { if (fIcuDfs == null) { super.setLocalPatternChars(newLocalPatternChars); return; } fIcuDfs.setLocalPatternChars(newLocalPatternChars); }
SimpleDateFormat sdf = new SimpleDateFormat(); // uses default locale (here for Germany) System.out.println(sdf.toPattern()); // dd.MM.yy HH:mm System.out.println(sdf.toLocalizedPattern()); // tt.MM.uu HH:mm DateFormatSymbols dfs = DateFormatSymbols.getInstance(Locale.GERMANY); dfs.setLocalPatternChars("GJMTkHmsSEDFwWahKzZYuXL"); sdf.setDateFormatSymbols(dfs); sdf.applyLocalizedPattern("TT.MM.JJJJ"); System.out.println(sdf.toPattern()); // dd.MM.yyyy System.out.println(sdf.toLocalizedPattern()); // TT.MM.JJJJ System.out.println(sdf.format(new Date())); // 20.06.2016
SakaiLocaleServiceProviderUtil.getString("AmPmStrings.AM", locale), SakaiLocaleServiceProviderUtil.getString("AmPmStrings.PM", locale) }); symbols.setLocalPatternChars(SakaiLocaleServiceProviderUtil.getString( "LocalPatternChars", locale));