Date and Calender (input string) conversion and manipulation in Java -
I am trying to solve this problem in Nepal as we use Bikram Sambat (BS) in our calendar And also use the Georgian calendar (AD). What I am trying to do is to convert ED and AD from BS to BS. BS is ahead of 56 years and 8 months ed. For example today: February 17, 2013 is 4 (day) 11 (month) 2070 (year) in BS.
Package day 10; Import java.util.Date; / ** * This is my driver class * / public class driver {public static zero major (string [] args) {dateUtils dateUtils = new dateUtils (); // Object creation date date = dateUtils.getCurrentDate (); // current date dateUtils.getAd ("10 21 2070"); // Laws invite you from BS to AD. (This is mm / dd / yyyy bs)}} package 1010; Import java.text.DateFormat; Import java.text.ParseException; Import java.text.SimpleDateFormat; Import java.util.Calendar; Import java.util.Date; / ** * To change date values, this is my service class I * / Last Public Category DateUtils {public date getCurrentDate () {Simple date format date format = new simple data format ("MMM DD yyyy"); // date format date date = new date (); // current date System.out.println (dateFormat format (date)); return date; } // Method Method to convert Edi Public Calendar from BS (String BS) {DateFormat dateFormat = New SimpleDateFormat ("MM dd yyyy"); // date format calendar ad = Calendar.getInstance (); // Change string value to calendar object {try ad.setTime (dateFormat.parse (bs)); } Hold (ParseException e) {System.out.println ("invalid"); } System.out.println ("Your Ad Date:" + dateFormat.format (bs)); Return advertisement; }} Issue: When trying to change the string format of the calendar, the variable could not be determined to store a new converted calendar value.
I am trying to change the calendar for string value and reduce it by 56 years and 8 months. Is this a good possible way?
Thank you.
If you want to add several years / months to a calendar now, you can do this as follows. But again, this is not the actual Eddy for BS conversion.
import java.text.SimpleDateFormat; Import java.util.Calendar; Import java.util.GregorianCalendar; Public class Test040 {public static zero main (string [] algs) {simple data formatting SDF = new simpledate format ("DD-MM-yyyy"); Calendar c = new gregorian calendar (); C.add (Calendar: IEER, 56); C.add (Calendar. MONTH, 8); C.getTime (); Println (sdf.format (c.getTime ())); }}
Comments
Post a Comment